2016-06-10 10:23:57 -05:00
.. _query_tool:
2015-02-23 04:51:47 -06:00
2018-06-15 03:14:12 -05:00
***** ***** ***** *** *
2019-02-15 09:44:49 -06:00
`Query Tool` :index:
2018-06-15 03:14:12 -05:00
***** ***** ***** *** *
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
The Query Tool is a powerful, feature-rich environment that allows you to
execute arbitrary SQL commands and review the result set. You can access the
Query Tool via the *Query Tool* menu option on the *Tools* menu, or through the
context menu of select nodes of the Browser tree control. The Query Tool
allows you to:
2016-06-10 10:23:57 -05:00
2018-01-11 10:58:30 -06:00
* Issue ad-hoc SQL queries.
2016-06-10 10:23:57 -05:00
* Execute arbitrary SQL commands.
2019-07-17 05:45:20 -05:00
* Edit the result set of a SELECT query if it is
:ref: `updatable <updatable-result-set>` .
2018-01-15 07:25:36 -06:00
* Displays current connection and transaction status as configured by the user.
2018-01-11 10:58:30 -06:00
* Save the data displayed in the output panel to a CSV file.
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
* Review the execution plan of a SQL statement in either a text, a graphical
format or a table format (similar to https://explain.depesz.com).
2016-06-10 10:23:57 -05:00
* View analytical information about a SQL statement.
2019-07-17 05:45:20 -05:00
2016-06-10 10:23:57 -05:00
.. image :: images/query_tool.png
2018-01-11 10:58:30 -06:00
:alt: Query tool window
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
You can open multiple copies of the Query tool in individual tabs
simultaneously. To close a copy of the Query tool, click the *X* in the
upper-right hand corner of the tab bar.
2016-06-10 10:23:57 -05:00
2018-01-11 10:58:30 -06:00
The Query Tool features two panels:
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
* The upper panel displays the *SQL Editor* . You can use the panel to enter,
edit, or execute a query. It also shows the *History* tab which can be used
to view the queries that have been executed in the session, and a *Scratch Pad*
which can be used to hold text snippets during editing. If the Scratch Pad is
closed, it can be re-opened (or additional ones opened) by right-clicking in
the SQL Editor and other panels and adding a new panel.
* The lower panel displays the *Data Output* panel. The tabbed panel displays
the result set returned by a query, information about a query's execution plan,
server messages related to the query's execution and any asynchronous
notifications received from the server.
2016-06-10 10:23:57 -05:00
2019-03-08 09:29:05 -06:00
Toolbar
***** **
The toolbar is described in the following subsections.
.. toctree ::
:maxdepth: 2
query_tool_toolbar
The SQL Editor Panel
***** ***** ***** *****
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
The *SQL editor* panel is a workspace where you can manually provide a query,
copy a query from another source, or read a query from a file. The SQL editor
features syntax coloring and autocompletion.
2016-11-09 03:48:44 -06:00
2016-06-10 10:23:57 -05:00
.. image :: images/query_sql_editor.png
2018-01-11 10:58:30 -06:00
:alt: Query tool editor
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
To use autocomplete, begin typing your query; when you would like the Query
editor to suggest object names or commands that might be next in your query,
2020-10-06 07:05:04 -05:00
press the Control+Space key combination. For example, type "*SELECT \* FROM*"
2019-02-15 09:44:49 -06:00
(without quotes, but with a trailing space), and then press the Control+Space
key combination to select from a popup menu of autocomplete options.
2016-06-10 10:23:57 -05:00
.. image :: images/query_autocomplete.png
2018-01-11 10:58:30 -06:00
:alt: Query tool autocomplete feature
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
After entering a query, select the *Execute/Refresh* icon from the toolbar. The
complete contents of the SQL editor panel will be sent to the database server
for execution. To execute only a section of the code that is displayed in the
SQL editor, highlight the text that you want the server to execute, and click
the *Execute/Refresh* icon.
2016-06-10 10:23:57 -05:00
.. image :: images/query_execute_section.png
2018-01-11 10:58:30 -06:00
:alt: Query tool execute query section
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
The message returned by the server when a command executes is displayed on the
*Messages* tab. If the command is successful, the *Messages* tab displays
execution details.
2016-06-10 10:23:57 -05:00
.. image :: images/query_tool_message.png
2018-01-11 10:58:30 -06:00
:alt: Query tool message panel
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
Options on the *Edit* menu offer functionality that helps with code formatting
and commenting:
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
* The auto-indent feature will automatically indent text to the same depth as
the previous line when you press the Return key.
2016-06-10 10:23:57 -05:00
* Block indent text by selecting two or more lines and pressing the Tab key.
2019-02-15 09:44:49 -06:00
* Implement or remove SQL style or toggle C style comment notation within your
code.
2016-06-10 10:23:57 -05:00
2019-06-27 09:30:05 -05:00
You can also **drag and drop** certain objects from the treeview which
can save time in typing long object names. Text containing the object name will be
fully qualified with schema. Double quotes will be added if required.
For functions and procedures, the function name along with parameter names will
be pasted in the Query Tool.
2016-06-10 10:23:57 -05:00
2019-03-08 09:29:05 -06:00
The Data Output Panel
***** ***** ***** ***** *
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
The *Data Output* panel displays data and statistics generated by the most
recently executed query.
2016-06-10 10:23:57 -05:00
.. image :: images/query_output_data.png
2018-01-11 10:58:30 -06:00
:alt: Query tool output panel
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
The *Data Output* tab displays the result set of the query in a table format.
You can:
2016-06-10 10:23:57 -05:00
2017-12-11 06:01:54 -06:00
* Select and copy from the displayed result set.
2019-02-15 09:44:49 -06:00
* Use the *Execute/Refresh* options to retrieve query execution information and
set query execution options.
2020-12-14 00:28:53 -06:00
* Use the *Save results to file* icon to save the content of the *Data Output*
2019-02-15 09:44:49 -06:00
tab as a comma-delimited file.
2019-07-17 05:45:20 -05:00
* Edit the data in the result set of a SELECT query if it is updatable.
.. _updatable-result-set:
A result set is updatable if:
2019-08-26 03:47:40 -05:00
* All columns are either selected directly from a single table, or
are not table columns at all (e.g. concatenation of 2 columns).
Only columns that are selected directly from the table are
editable, other columns are read-only.
* All the primary key columns or OIDs of the table are selected in the
result set.
Any columns that are renamed or selected more than once are also read-only.
Editable and read-only columns are identified using pencil and lock icons
(respectively) in the column headers.
.. image :: images/query_tool_editable_columns.png
:alt: Query tool editable and read-only columns
:align: center
2019-07-17 05:45:20 -05:00
2019-08-01 07:59:53 -05:00
The psycopg2 driver version should be equal to or above 2.8 for updatable
query result sets to work.
2019-08-26 03:47:40 -05:00
An updatable result set is identical to the :ref: `Data Grid <data-grid>` in
View/Edit Data mode, and can be modified in the same way.
2019-07-17 05:45:20 -05:00
If Auto-commit is off, the data changes are made as part of the ongoing
transaction, if no transaction is ongoing a new one is initiated. The data
changes are not committed to the database unless the transaction is committed.
If any errors occur during saving (for example, trying to save NULL into a
column with NOT NULL constraint) the data changes are rolled back to an
automatically created SAVEPOINT to ensure any previously executed queries in
the ongoing transaction are not rolled back.
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
All rowsets from previous queries or commands that are displayed in the *Data
Output* panel will be discarded when you invoke another query; open another
2019-03-08 09:29:05 -06:00
Query Tool tab to keep your previous results available.
2016-06-10 10:23:57 -05:00
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
Explain Panel
***** ***** ***
2016-06-10 10:23:57 -05:00
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
To generate the *Explain* or *Explain Analyze* plan of a query, click on
*Explain* or *Explain Analyze* button in the toolbar.
More options related to *Explain* and *Explain Analyze* can be selected from
the drop down on the right side of *Explain Analyze* button in the toolbar.
.. image :: images/query_toolbar_explain.png
:alt: Query tool toolbar explain button
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
Please note that pgAdmin generates the *Explain [Analyze]* plan in JSON format.
On successful generation of *Explain* plan, it will create three tabs/panels
under the Explain panel.
* Graphical
2021-01-12 05:13:30 -06:00
Please note that *EXPLAIN VERBOSE* cannot be displayed graphically. Click on
a node icon on the *Graphical* tab to review information about that item; a popup
window will display on the right side with the information about the selected
object. For information on JIT statistics, triggers and a summary, click on the
button on top-right corner; a similar popup window will be displayed when appropriate.
2019-02-15 09:44:49 -06:00
Use the download button on top left corner of the *Explain* canvas to download
the plan as an SVG file.
2016-06-10 10:23:57 -05:00
2018-12-13 04:49:56 -06:00
**Note:** Download as SVG is not supported on Internet Explorer.
2016-06-10 10:23:57 -05:00
.. image :: images/query_output_explain_details.png
2018-01-11 10:58:30 -06:00
:alt: Query tool graphical explain plan
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
Note that the query plan that accompanies the *Explain analyze* is available on
the *Data Output* tab.
2016-06-10 10:23:57 -05:00
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
* Table
*Table* tab shows the plan details in table format, it generates table format
2021-12-09 05:29:43 -06:00
similar to *explain.depesz.com* . Each row of the table represent the data for a
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
*Explain Plan Node* . It may contain the node information, exclusive timing,
inclusive timing, actual vs planned rows differences, actual rows, planned
rows, loops.
background color of the exclusive, inclusive, and Rows X columns may vary based on the
difference between actual vs planned.
If percentage of the exclusive/inclusive timings of the total query time is:
> 90 - Red color
> 50 - Orange (between red and yellow) color
> 10 - Yellow color
If planner mis-estimated number of rows (actual vs planned) by
10 times - Yellow color
100 times - Orange (between Red and Yellow) color
1000 times - Red color
.. image :: images/query_explain_analyze_table.png
:alt: Query tool explain plan table
:align: center
* Statistics
*Statistics* tab shows two tables:
1. Statistics per Plan Node Type
2. Statistics per Table
.. image :: images/query_explain_analyze_statistics.png
:alt: Query tool explain plan statistics
:align: center
Messages Panel
***** ***** *** *
2019-02-15 09:44:49 -06:00
Use the *Messages* tab to view information about the most recently executed
query:
2016-06-10 10:23:57 -05:00
.. image :: images/query_output_error.png
2018-01-11 10:58:30 -06:00
:alt: Query tool output messages
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2019-02-15 09:44:49 -06:00
If the server returns an error, the error message will be displayed on the
*Messages* tab, and the syntax that caused the error will be underlined in the
SQL editor. If a query succeeds, the *Messages* tab displays how long the
query took to complete and how many rows were retrieved:
2016-06-10 10:23:57 -05:00
.. image :: images/query_output_messages.png
2018-01-11 10:58:30 -06:00
:alt: Query tool output information
2019-03-08 09:29:05 -06:00
:align: center
2016-06-10 10:23:57 -05:00
2021-04-12 00:58:48 -05:00
Notifications Panel
***** ***** ***** *** *
Use the *Notifications* tab to view the notifications using PostgreSQL *Listen/
Notify* feature. For more details see `PostgreSQL documentation <https://
www.postgresql.org/docs/current/sql-listen.html>`_.
Example:
1. Execute *LISTEN "foo"* in first *Query Tool* session
.. image :: images/query_output_notifications_listen.png
:alt: Query tool notifications listen
:align: center
2. In the another *Query Tool* session, execute *Notify* command or *pg_notify*
function to send the notification of the event together with the payload.
.. image :: images/query_output_notifications_notify.png
:alt: Query tool notifications notify
:align: center
3. You can observe the *Notification* tab in the first *Query Tool* session
where it shows the Recorded time, Event, Process ID, and the Payload of the
particular channel.
.. image :: images/query_output_notifications_panel.png
:alt: Query tool notifications panel
:align: center
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
Query History Panel
***** ***** ***** *** *
2017-12-11 06:01:54 -06:00
Use the *Query History* tab to review activity for the current session:
2016-06-10 10:23:57 -05:00
.. image :: images/query_output_history.png
2018-01-11 10:58:30 -06:00
:alt: Query tool history panel
2019-03-08 09:29:05 -06:00
:align: center
2016-11-09 03:48:44 -06:00
2018-01-11 10:58:30 -06:00
The Query History tab displays information about recent commands:
2016-11-09 03:48:44 -06:00
* The date and time that a query was invoked.
* The text of the query.
* The number of rows returned by the query.
2019-02-15 09:44:49 -06:00
* The amount of time it took the server to process the query and return a
result set.
2016-11-09 03:48:44 -06:00
* Messages returned by the server (not noted on the *Messages* tab).
2019-08-16 06:47:12 -05:00
* The source of the query (indicated by icons corresponding to the toolbar).
You can show or hide the queries generated internally by pgAdmin (during
'View/Edit Data' or 'Save Data' operations).
2016-11-09 03:48:44 -06:00
2022-04-26 05:48:28 -05:00
You can remove a single query by selecting it and clicking on the *Remove*
button. If you would like to remove all of the histories from the
*Query History* tab, then click on the *Remove All* button.
By using the *Copy* button, you can copy a particular query to the clipboard,
and with the *Copy to Query Editor* button, you can copy a specific query to
the Query Editor tab. During this operation, all existing content in the
Query Editor is erased.
2018-01-15 07:25:36 -06:00
2019-03-13 08:37:34 -05:00
Query History is maintained across sessions for each database on a per-user
basis when running in Query Tool mode. In View/Edit Data mode, history is not
retained. By default, the last 20 queries are stored for each database. This
2020-07-17 07:24:12 -05:00
can be adjusted in `` config_local.py `` or `` config_system.py `` (see the
:ref: `config.py <config_py>` documentation) by overriding the
`MAX_QUERY_HIST_STORED` value. See the :ref: `Deployment <deployment>` section
for more information.
2019-03-13 08:37:34 -05:00
Fixes # 4778 - Implement the query plan analyzer
Look 'n' Feel and implementation logic are inspired from
'http://explain.depsez.com'.
It now creates three tabs under the 'Explain' panel when executing a
query using the Explain Analyze/Explain button from the toolbar of the
Query tool.
Graphical
---------
-> Graphical Explain Plan
Analysis
--------
-> Table to show details of the explain plan analyse.
-> Each row represents the statistics per Explain Plan Node
-> It may contains columns like node information, exclusive timing
(time spent for this explain node excluding the child nodes),
inclusive timing, actual rows, plan rows,
rowsx (misestimation between planned vs actual rows), loop.
-> Background color of exclusive, inclusive, rows changes based on
their values.
i.e.
If Percentage of exclusive, and inclusive timings of total query time
is:
> 90 - Red Color
> 50 - Orange (Between Red & Yellow Color)
> 10 - Yellow color
If planner misestimation for the rows is
> 1000 times - Red Color
> 100 times - Orange (Between Red & Yellow Color)
> 10 times - Yellow Color
Also - if actual rows <= planned rows then it shows up arrow, else it
shows down arrow.
Statistics
----------
-> It contains a HTML table for the statistics per Node Type, and
a HTML table for the statistics per table.
Reviewed by: Akshay Joshi
2019-10-08 06:03:25 -05:00
Connection Status
***** ***** ***** **
2019-02-15 09:44:49 -06:00
Use the *Connection status* feature to view the current connection and
2019-03-08 09:29:05 -06:00
transaction status by clicking on the status icon in the Query Tool:
2018-01-15 07:25:36 -06:00
.. image :: images/query_tool_connection_status.png
2019-02-22 08:28:05 -06:00
:alt: Query tool connection and transaction statuses
2019-03-08 09:29:05 -06:00
:align: center
2020-10-01 02:59:00 -05:00
Change connection
***** ***** ***** **
User can connect to another server or database from existing open session of query tool.
* Click on the connection link next to connection status.
* Now click on the *<New Connection>* option from the dropdown.
2022-04-26 05:48:28 -05:00
.. image :: images/query_tool_new_connection_options.png
2020-10-01 02:59:00 -05:00
:alt: Query tool connection options
:align: center
2022-04-26 05:48:28 -05:00
* Now select server, database, user, and role to connect and click on the 'Save' button.
2020-10-01 02:59:00 -05:00
2022-04-26 05:48:28 -05:00
.. image :: images/query_tool_new_connection_dialog.png
2020-10-01 02:59:00 -05:00
:alt: Query tool connection dialog
:align: center
* A newly created connection will now get listed in the options.
* To connect, select the newly created connection from the dropdown list.
2020-10-06 07:05:04 -05:00
Macros
***** *
2020-10-12 05:43:34 -05:00
Query Tool Macros enable you to execute pre-defined SQL queries with a single key press. Pre-defined queries can contain the placeholder $SELECTION$. Upon macro execution, the placeholder will be replaced with the currently selected text in the Query Editor pane of the Query Tool.
2020-10-06 07:05:04 -05:00
2020-10-12 05:43:34 -05:00
.. image :: images/query_tool_manage_macros.png
:alt: Query Tool Manage macros
:align: center
To create a macro, select the *Manage Macros* option from the *Macros* menu on the *Query Tool* . Select the key you wish to use, enter the name of the macro, and the query, optionally including the selection placeholder, and then click the *Save* button to store the macro.
2020-10-06 07:05:04 -05:00
.. image :: images/query_tool_manage_macros_dialog.png
:alt: Query Tool Manage Macros dialogue
:align: center
2022-04-26 05:48:28 -05:00
To delete a macro, select the macro on the *Manage Macros* dialogue, and then click the *Delete* button.
The server will prompt you for confirmation to delete the macro.
2020-10-06 07:05:04 -05:00
.. image :: images/query_tool_macros_clear_confirmation.png
:alt: Query Tool Manage Macros Clear row confirmation
:align: center
2020-10-12 05:43:34 -05:00
To execute a macro, simply select the appropriate shortcut keys, or select it from the *Macros* menu.
2020-10-06 07:05:04 -05:00
.. image :: images/query_tool_macros_execution.png
:alt: Query Tool Macros Execution
:align: center