Repository navigation
feat(editor): chart each EXPLAIN tree node against the largest step in the plan (#2633) - #2636
Merged
Merged
Conversation
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Automations to automatically generate PRs for you. |
Member
Author
|
Screenshots of the new column, captured by driving a Debug build against a local PostgreSQL 17. The docs images in the diff are the same two shots. They are 1512x861 rather than the 3026x1720 the other |
…e-bar-chart # Conflicts: # CHANGELOG.md
Signed-off-by: Ngô Quốc Đạt <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the bar chart #2633 asked for: a sortable magnitude column in the EXPLAIN tree, with a Metric menu above it. Each row's bar is drawn against the largest step in the plan, so the expensive node stands out without reading eight-digit numbers down a column.
Three defects had to be fixed first, because the bar is drawn from the numbers they get wrong.
Before / After
The tree before this change is the one in the issue:
Operation,Cost,RowsandActual Time, all plain right-aligned text, with nothing on a row proportional to any value.After, against a real PostgreSQL 17
EXPLAIN (ANALYZE, FORMAT JSON):The
Seq Scanfills the track and reads red at 21,513 ms of a 29,292 ms query.Gather MergeandHash Joinare visibly short.Limitat 0,019 ms still draws a hairline rather than nothing, so "tiny" stays distinguishable from "not reported".Both
docs/images/explain-tree.pngand its dark twin are re-captured, since they pictured the old column set. They are 1512x861 because the display attached here is 1x; the originals were 3026x1720, so they are accurate but half resolution and worth re-shooting on a Retina display.The bar
Length is
value / largest node, linear. Colour comes fromQueryPlanSeverity, from the share of the plan for an additive metric and from the largest node for a row count, because rows are re-reported by every ancestor and a "share" of them means nothing. A non-zero value never rounds away to an empty track.The metric menu offers only what the plan reports, and the column is titled by the metric it charts:
exclusiveCostMeasured plans default to Self Time, estimated ones to Self Cost. The stored choice is never overwritten by a plan that cannot offer it, so opening a SQLite plan does not lose the metric picked for PostgreSQL.
Canvasdraws it, which is what the plan diagram beside it already uses. Not a progress control: the HIG calls progress indicators transient and says a stationary one reads as a stalled app. NotGauge:.linearis@available(macOS, unavailable). Not Swift Charts: the vectorizedBarPlotpath is macOS 15.NSLevelIndicator.relevancyis the style the HIG names for comparing items, but a compiled probe against the real framework showed it draws no fill at any value and ignoresfillColor, so it has no channel for severity.The three fixes underneath
costFractioncould exceed 1, and the badge inverted. It divided a node's exclusive cost by the root's total, and PostgreSQL prices aLimitfar below its child on purpose. Replayed against a live PostgreSQL 17:ORDER BY id LIMIT 2gave the Gather Merge 5.626, a merge join gave an Index Scan 11.828, against a doc comment promising 0.0-1.0 and aQueryPlanSeveritywith no arm above.critical. The denominator is now the sum of every node's exclusive cost, which is what a share means, always lands in 0...1 and is identical wherever the old value was already in range. Node by node across five real plans, the LIMIT plan changes 2 of its 4 badges (aSeq Scandoing 11% of the work stops claiming to be critical) and the other four change 0 of 18.A plan that reports nothing claimed every node was cheap.
costFractiondefaulted to 0 and 0 is.low, so SQLite, ClickHouse, DuckDB and Dameng plans painted a green "Low cost" dot on every row and said so to VoiceOver.severityis now optional: no cost, no badge, no claim. The glyph's footprint is reserved rather than removed, because a plan can price some nodes and not others and the operation text has to keep one left edge.Columns the plan cannot fill are hidden. A SQLite plan used to show three permanently empty columns; it now lists its steps and nothing else, and a CockroachDB plan keeps
Rowswhile droppingCostandActual Time. Driven byisHiddenand written in both directions on every update: measured,removeTableColumnthenaddTableColumnstrands the column at the end of the header and resets the width the user chose, while hiding preserves both.The outline's
autosaveNameis bumped to.v2. Measured: with a saved four-column layout, AppKit restores what it knows in the saved order and appends anything it has never seen, so the bar column would have arrived stranded pastActual Timefor everyone who had ever resized a plan column. The cost is a one-time reset of plan-outline column widths.Loops and workers
PostgreSQL reports actual time and rows as per-execution averages. Measured here: an inner Index Scan at
Actual Loops: 500reportsActual Total Time: 0.000, and under a Gather with 2 workers launched a Seq Scan reportsActual Loops: 3against an execution time of 83 ms. So Self Time multiplies by loops and divides by the worker count, and the divisor belongs to a Gather's descendants, not the Gather itself, which runs once in the leader. Applying it to the Gather too reported 40.23 ms for a node measured at 120.697 ms. With it right, the self times of a plan sum to its execution time (120.701 against 120.728), which is the invariant that makes Self Time additive and its share meaningful.The
Actual Timecolumn is untouched and still shows the per-loop figure. That is documented behaviour, pinned byMySQLPlanParserTests, and what psql, pgAdmin and DBeaver show. Self Time is a separate, differently named metric.Also fixed, found while investigating
Workers Launched: 0was hidden.visiblePropertiesdropped any"0", so a Gather reportingWorkers Planned: 2, Workers Launched: 0showed the 2 and swallowed the 0, which is the answer to why the query was slow. Confirmed against a server withmax_parallel_workers = 0. A small set of keys whose zero is the answer is now exempt.cost_info.read_cost, so theQuery Blocknode absorbed every table'seval_costas its own exclusive cost and came out the reddest node in every MySQL plan. It now takesread_cost + eval_cost, and only wheneval_costis present, so a plan without it reads exactly as before. Validated on MariaDB 12.3, where the per-table costs sum exactly to the block cost (0.0923548 + 0.9166336 = 1.0089884); not validated against a real MySQL server, which was not available here and for which MySQL publishes nocost_infoexample, so that arm follows its documented cost model rather than a measurement.Verification
buildPASS,test116 executed, 116 passed across 14 suites,swiftlint --strictclean on the app and test paths,docsPASS.QueryPlanMetricIndexTests,QueryPlanLoopCorrectionTests, whose fixtures are verbatim PostgreSQL 17 output rather than invented numbers.QueryPlanCostTests,QueryPlanSeverityTests,QueryPlanNodeSummaryTests,QueryPlanOutlineSortTests,PostgreSQLPlanParserTests,MySQLPlanParserTests.testAMetriclessPlanShowsNoEmptyColumnsAndNoMetricChooserpins that the chooser is absent and the empty columns are gone. The populated bar cannot be UI-tested without a server, so it was verified by driving a Debug build against a local PostgreSQL 17 instead, which is where the screenshots come from.You've hit your usage limit ... try again at Sep 7th.Skill(code-review)ran in its place.Fixes #2633
https://claude.ai/code/session_015jGG9vt2GwiTxNk1FHKBCJ