Repository navigation
feat(explain): ask for the plan in JSON or as an iterator tree - #657
Merged
Merged
Conversation
EXPLAIN only ever asked for the tabular plan. That form rounds off the numbers worth having: `query_cost`, `read_cost`, `rows_examined_per_scan` and `filtered` all live in `EXPLAIN FORMAT=JSON`, and the iterator tree is the shape `EXPLAIN ANALYZE` reports in, so it is the one to compare a timed run against. A Format picker on the plan panel re-plans the last statement in the chosen shape. JSON renders as a collapsible tree with the cost and row keys picked out — pretty-printed text would bury them four levels down. The combinations the servers do not have are resolved in Rust rather than left to fail: - MariaDB has no FORMAT=TREE (error 1791), so it gets the tabular plan and the panel says why. - MySQL before 8.3 cannot combine ANALYZE with JSON (error 1235), so the plan comes back in JSON without the timings, and the panel says so. - MariaDB spells the timed JSON form `ANALYZE FORMAT=JSON`, which does carry the timings. Every one of those was checked against MySQL 8.0.46 and MariaDB 11.8 before it was written down, and there is a test asserting no combination of format, analyze and server produces a statement neither will run. The ANALYZE safety check is unchanged and applies to every format — there is a test that plans a DELETE in each of the three and confirms it is refused. +8 Rust unit tests, +5 live-server tests (passing on both servers), +8 frontend tests.
9 of 16 tasks
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.
Closes #424.
EXPLAIN only ever asked for the tabular plan, which rounds off the numbers worth having.
EXPLAIN FORMAT=JSONcarriesquery_cost,read_cost,rows_examined_per_scanandfiltered;FORMAT=TREEis the iterator tree, which is the shapeEXPLAIN ANALYZEreports in and therefore the one to compare a timed run against.What it looks like
A Format picker on the plan panel re-plans the last statement in the chosen shape — a select rather than three buttons, because the panel already has a Table/Tree toggle for how to draw the tabular plan and a second "Tree" beside it would be two different things wearing the same word.
JSON renders as a collapsible tree with the cost and row keys picked out. Pretty-printed text would bury them: in a plan for a real query,
query_costis four levels down.The combinations the servers do not have
Resolved in Rust rather than left to fail, because an error where a plan should be is a worse answer than the plan you can have:
FORMAT=TREEANALYZE FORMAT=JSON, which does carryr_total_time_msEvery row of that table was run against MySQL 8.0.46 and MariaDB 11.8 before it was written down. There is also a test that sweeps all twelve combinations of format × analyze × server and asserts none of them builds a statement neither server would run.
The ANALYZE safety check (#412) is untouched and applies to every format — a test plans a
DELETEin each of the three and confirms it is refused in all of them.Tests
+8 Rust unit tests on the statement builder, +5 live-server tests (passing on both servers), +8 frontend tests. 2723 unit, 344 browser.
One thing found while doing this
Running the EXPLAIN integration suite against MariaDB turned up a real bug that is not about EXPLAIN: after a query timeout, the timed-out connection is never returned to the pool, so
pool_maxtimeouts exhaust the pool anddisconnecthangs. On MySQL the same code recovers immediately. Filed and fixed separately — this PR leaves a note at the port override pointing at it.