Skip to content

Commit

Permalink
Added WAL option to EXPLAIN ANALYZE command. #6382
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay-joshi committed Aug 3, 2023
1 parent 59c4a00 commit 1a7a23d
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 4 deletions.
Binary file modified docs/en_US/images/preferences_sql_explain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified docs/en_US/images/query_toolbar_explain.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 12 additions & 3 deletions docs/en_US/preferences.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
4 changes: 4 additions & 0 deletions docs/en_US/query_tool_toolbar.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
+----------------------+---------------------------------------------------------------------------------------------------+----------------+
Expand Down
3 changes: 2 additions & 1 deletion docs/en_US/release_notes_7_6.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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.
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

Expand Down Expand Up @@ -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,
});
}
}
Expand Down Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
@@ -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 }}
22 changes: 22 additions & 0 deletions web/pgadmin/tools/sqleditor/tests/test_explain_plan_templates.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 6 additions & 0 deletions web/pgadmin/tools/sqleditor/utils/query_tool_preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 1a7a23d

Please sign in to comment.