Added WAL option to EXPLAIN ANALYZE command. #6382

This commit is contained in:
Akshay Joshi 2023-08-03 15:57:12 +05:30
parent 59c4a00134
commit 1a7a23de3f
9 changed files with 70 additions and 4 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 54 KiB

After

Width:  |  Height:  |  Size: 93 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 139 KiB

View File

@ -396,16 +396,25 @@ Use the fields on the *Editor* panel to change settings of the query editor.
Use the fields on the *Explain* panel to specify the level of detail included in
a graphical EXPLAIN.
* When the *Show Buffers?* switch is set to *True*, graphical explain details
* When the *Show buffers?* switch is set to *True*, graphical explain details
will include information about buffer usage.
* When the *Show Costs?* switch is set to *True*, graphical explain details will
* When the *Show costs?* switch is set to *True*, graphical explain details will
include information about the estimated startup and total cost of each plan,
as well as the estimated number of rows and the estimated width of each row.
* When the *Show Timing?* switch is set to *True*, graphical explain details
* When the *Show settings?* switch is set to *True*, graphical explain details
will include the information on the configuration parameters.
* When the *Show summary?* switch is set to *True*, graphical explain details
will include the summary information about the query plan.
* When the *Show timing?* switch is set to *True*, graphical explain details
will include the startup time and time spent in each node in the output.
* When the *Show wal?* switch is set to *True*, graphical explain details
will include the information on WAL record generation.
* When the *Verbose output?* switch is set to *True*, graphical explain details
will include extended information about the query execution plan.

View File

@ -146,6 +146,10 @@ Query Execution
| | spent in each node of the query. | |
| | | |
| | * Select *Summary* to include the summary information about the query plan. | |
| | | |
| | * Select *Settings* to include the information on the configuration parameters. | |
| | | |
| | * Select *Wal* to include the information on WAL record generation. | |
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
| *Commit* | Click the *Commit* icon to commit the transaction. | Shift+CTRL+M |
+----------------------+---------------------------------------------------------------------------------------------------+----------------+

View File

@ -24,6 +24,7 @@ New features
| `Issue #6375 <https://github.com/pgadmin-org/pgadmin4/issues/6375>`_ - Added support for ALTER INDEX column statistics.
| `Issue #6376 <https://github.com/pgadmin-org/pgadmin4/issues/6376>`_ - Added unlogged option while creating a sequence.
| `Issue #6381 <https://github.com/pgadmin-org/pgadmin4/issues/6381>`_ - Added support for SYSTEM, CONCURRENTLY and TABLESPACE options in REINDEX.
| `Issue #6382 <https://github.com/pgadmin-org/pgadmin4/issues/6382>`_ - Added WAL option to EXPLAIN ANALYZE command.
| `Issue #6397 <https://github.com/pgadmin-org/pgadmin4/issues/6397>`_ - Added new/missing options to the VACUUM command.
| `Issue #6415 <https://github.com/pgadmin-org/pgadmin4/issues/6415>`_ - Added SKIP_LOCKED and BUFFER_USAGE_LIMIT option to Analyze command.
| `Issue #6448 <https://github.com/pgadmin-org/pgadmin4/issues/6448>`_ - Add support for TRUNCATE trigger in foreign table.
@ -37,6 +38,6 @@ Bug fixes
*********
| `Issue #5454 <https://github.com/pgadmin-org/pgadmin4/issues/5454>`_ - Fix incorrect redirection URL after authentication by removing fixed value set to SCRIPT_NAME environment variable in pgAdmin4.wsgi file.
| `Issue #6500 <https://github.com/pgadmin-org/pgadmin4/issues/6500>`_ - Fix the issue where query tool window turns blank if the user tries to generate a graph on the result.
| `Issue #6252 <https://github.com/pgadmin-org/pgadmin4/issues/6252>`_ - Fix an issue where query tool on shared server is throwing error if the pgAdmin config DB is external.
| `Issue #6500 <https://github.com/pgadmin-org/pgadmin4/issues/6500>`_ - Fix the issue where query tool window turns blank if the user tries to generate a graph on the result.
| `Issue #6624 <https://github.com/pgadmin-org/pgadmin4/issues/6624>`_ - Fix an issue where changing MFA_SUPPORTED_METHODS breaks the MFA validation.

View File

@ -185,6 +185,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
timing: analyze ? Boolean(checkedMenuItems['explain_timing']) : false,
summary: Boolean(checkedMenuItems['explain_summary']),
settings: Boolean(checkedMenuItems['explain_settings']),
wal: analyze ? Boolean(checkedMenuItems['explain_wal']) : false,
});
}, [checkedMenuItems]);
@ -381,6 +382,7 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
explain_timing: queryToolPref.explain_timing,
explain_summary: queryToolPref.explain_summary,
explain_settings: queryToolPref.explain_settings,
explain_wal: queryToolPref.explain_wal,
});
}
}
@ -623,6 +625,8 @@ export function MainToolBar({containerRef, onFilterClick, onManageMacros}) {
onClick={checkMenuClick}>{gettext('Summary')}</PgMenuItem>
<PgMenuItem hasCheck value="explain_settings" checked={checkedMenuItems['explain_settings']}
onClick={checkMenuClick}>{gettext('Settings')}</PgMenuItem>
<PgMenuItem hasCheck value="explain_wal" checked={checkedMenuItems['explain_wal']}
onClick={checkMenuClick}>{gettext('Wal')}</PgMenuItem>
</PgMenu>
<PgMenu
anchorRef={macrosMenuRef}

View File

@ -0,0 +1,20 @@
{% import 'sql/macros/utils.macros' as UTILS %}
EXPLAIN ({% if format -%}
FORMAT {{ format.upper() }}
{%- endif %}{% if analyze is defined -%}
, ANALYZE {{ UTILS.BOOL_TEXT(analyze) }}
{%- endif %}{% if verbose is defined -%}
, VERBOSE {{ UTILS.BOOL_TEXT(verbose) }}
{%- endif %}{% if costs is defined -%}
, COSTS {{ UTILS.BOOL_TEXT(costs) }}
{%- endif %}{% if timing is defined -%}
, TIMING {{ UTILS.BOOL_TEXT(timing) }}
{%- endif %}{% if buffers is defined -%}
, BUFFERS {{ UTILS.BOOL_TEXT(buffers) }}
{%- endif %}{% if summary is defined -%}
, SUMMARY {{ UTILS.BOOL_TEXT(summary) }}
{%- endif %}{% if settings is defined -%}
, SETTINGS {{ UTILS.BOOL_TEXT(settings) }}
{%- endif %}{% if wal is defined -%}
, WAL {{ UTILS.BOOL_TEXT(wal) }}
{%- endif %}) {{ sql }}

View File

@ -61,6 +61,28 @@ class TestExplainPlanTemplates(BaseTestGenerator):
'SELECT * FROM places'
)
),
(
'When rendering Postgres 13 template, '
'when wal is present,'
'it returns the explain plan with wal',
dict(
template_path='sqleditor/sql/13_plus/explain_plan.sql',
input_parameters=dict(
sql='SELECT * FROM places',
format='json',
buffers=False,
timing=False,
summary=False,
wal=True
),
sql_statement='SELECT * FROM places',
expected_return_value='EXPLAIN '
'(FORMAT JSON, TIMING false, '
'BUFFERS false, SUMMARY false, '
'WAL true) '
'SELECT * FROM places'
)
),
]
def setUp(self):

View File

@ -55,6 +55,12 @@ def register_query_tool_preferences(self):
category_label=PREF_LABEL_EXPLAIN
)
self.explain_wal = self.preference.register(
'Explain', 'explain_wal',
gettext("Show wal?"), 'boolean', False,
category_label=PREF_LABEL_EXPLAIN
)
self.auto_commit = self.preference.register(
'Options', 'auto_commit',
gettext("Auto commit?"), 'boolean', True,