Help › Run queries
Compare two query plans
See two execution plans of a statement side by side, before and after an index or on two connections, with what changed and by how much.
Querlyn 0.1.0 is not released yet. This help describes it ahead of release.
When a query got faster or slower, two plans say why: before and after you added an index, or the same statement on staging and on production. Querlyn puts two plans side by side, pairs their steps, marks what changed, and lists the largest differences first.
Keep plans to compare
Every plan that Explain or Explain Analyze shows in a query tab is kept in that tab, the newest first: up to 20 per tab, with the statement, the connection, the database, the time and the server's version. Kept plans are in memory only. They go when you close the tab or quit Querlyn, and they are never written to disk or the query history.
Compare the last two plans
Choose Compare in the bar above a plan, , or in the command palette. A new tab compares:
- the tab's last two plans, older on the left; or
- when the tab has one plan, it and the newest plan of another tab, preferring one of the same statement; or
- otherwise the newest two plans of any open tab.
Each side has a picker above it that lists every kept plan of the open tabs, so either side can be any of them: a plan from this morning against one from now, or one tab against another. exchanges the sides.
A typical round:
- Put the cursor in the slow statement and choose Analyze.
- Create the index you think helps.
- Choose Analyze again, then Compare.
Compare two connections
To see the same statement's plan on another connection, choose On Another Connection in the bar above a plan, , or . Choose the connection and Explain or Explain Analyze, then Explain (↩ on macOS or Enter on Windows and Linux; ⎋ on macOS or Esc on Windows and Linux closes the dialog).
Querlyn opens the statement in a new query tab on that connection, explains it there, and opens the comparison as soon as both plans arrive: this tab's on the left, the other connection's on the right. If this tab has no plan of the statement yet, it is explained here too. The new tab is an ordinary tab: its messages say why an explain failed, and you can change the statement there and explain it again.
Only connections whose statements are read like this tab's are offered. A statement with parameters is not explained on another connection: write the values into it first.
Warning: Explain Analyze runs the statement, inside a transaction that
is always rolled back. On another connection it measures only statements
that read: an UPDATE, a DELETE, or a statement that may write in
some other way is refused before anything runs. To measure a write
there, use Analyze in that connection's tab, where the connection's
safety settings ask first.
Read the comparison
At the top, each side says which plan it is, where it ran, the statement and its totals. Below, what changed comes first: the totals ("Total time 31.92 ms → 1.3 ms (25× faster)"), then each difference, the largest first:
| Mark | Difference |
|---|---|
| ◆ | A step reads through another index, or none any more ("orders now uses idx_orders_customer (Bitmap Heap Scan) instead of Seq Scan"), or does something else (a hash join became a nested loop). |
| ↕ | The tables are read in another order (join order). |
| + and − | A step only one plan has. |
| ▲ | A row estimate that is off by ten times or more in the newer plan, or no longer. |
| • | The same step taking much more or much less time or cost. |
A click on a difference selects its row. Times are compared when both plans were analyzed, else estimated costs; a line under the differences says when only costs, or only the steps, could be compared.
The trees are side by side, one step per row with its rows, loops and own time or cost. Steps are paired by the table they read, then by the tables below them, then by their place in the tree. A row is tinted when the step changed, is new (right) or is gone (left). When the join order changed, a step can sit in a different place in each tree: it is marked ↕ on two rows, and selecting one outlines the other. A much lower time or cost on the right is green, a much higher one red.
| To | Do this |
|---|---|
| Move through the rows | ↑ on macOS or Up on Windows and Linux, ↓ on macOS or Down on Windows and Linux, ⇞ on macOS or PageUp on Windows and Linux, ⇟ on macOS or PageDown on Windows and Linux, ↖ on macOS or Home on Windows and Linux, ↘ on macOS or End on Windows and Linux |
| Go to the next or previous difference | F7 () and ⇧F7 on macOS or Shift+F7 on Windows and Linux (), or Next and Previous in the bar |
| See both steps value by value | Details (): every number and every property the database reports, such as buffers and conditions, left and right, with the ones that differ marked |
| Copy what changed as text | Copy Summary () |
What is compared, by database
Every database that shows plans in Querlyn can be compared. How well steps pair depends on what its plans say about each step:
| Database | Steps paired by | Compared |
|---|---|---|
| PostgreSQL, YugabyteDB | The table and index each step reads | Own times when both plans were analyzed, else costs; rows and loops; buffers in the details |
| MySQL, MariaDB | The table and index each step reads | Own times when both were analyzed, else costs; rows and loops |
| SQL Server | The table and index of each operator | Own times when both were analyzed, else costs; rows |
| Oracle Database | The table of each access; an index step goes with the table access above it | Own times when both were analyzed, else costs; rows |
| Amazon Redshift | The table each step reads | Costs and rows |
| DuckDB | The table each step reads | Own times when both were analyzed; rows |
| CockroachDB, TiDB | The table and index each step reads | The steps and their rows |
| SQLite | The table of each scan and search, and its index | The steps |
| ClickHouse, Snowflake | The table each step reads (and a ClickHouse skipping index) | The steps; their rows, parts or bytes in the details |
| BigQuery | Each stage's place in the plan | The stages; their rows and bytes in the details |
| MongoDB | The collection each scan reads, and its index | Own times when both were analyzed; documents and keys examined in the details |
| Cassandra | Nothing: a trace's steps name no table | The steps of each node and their times |
Two plans of different databases can be put side by side, but their steps seldom pair.
Screen-share mode
Plans quote the values in a statement's conditions. Where masked columns are masked, a condition that names a masked column shows every value in it as the mask, in the plan view and in a comparison, and the side is marked Values masked. The plan view's Raw tab then hides the database's original output, and Copy Plan copies nothing. The comparison's summary is built from what is shown, so Copy Summary never carries a masked value.
Help for Querlyn 0.1.0. All help topics