Repository navigation
feat(explain): plan trees and the most expensive node for PostgreSQL, MySQL and SQLite (#1164) - #1227
Merged
Merged
Conversation
… MySQL and SQLite (#1164) Explain showed the plan as text lines, and finding the expensive node meant reading indentation. Parsers build a tree of operations from the JSON plans of PostgreSQL and MySQL and from the rows of SQLite's EXPLAIN QUERY PLAN. Each node has its own cost (its cumulative cost minus its children's); the node with the largest own cost is the one to highlight. Tests use recorded plans.
Each driver gives the plan as a tree: PostgreSQL EXPLAIN (FORMAT JSON), MySQL EXPLAIN FORMAT=JSON, SQLite EXPLAIN QUERY PLAN rows. The result area of an explained query shows the tree with the most expensive node highlighted and each node's share of the cost as a bar, and a Plan | Text switch keeps the text plan. A driver without a tree, or a plan that cannot be read, keeps the text only.
…gives no tree (#1164) MySQL's prefix_cost is cumulative along the nested loop, so each table now keeps its own part, and the query block's cost is the sum of its tables'. A plan text that is not JSON gives no tree instead of throwing.
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.
Refs #1164
What was wrong
Explain showed the plan as text lines; finding the expensive node in a nested plan meant reading indentation.
Changes
query_plan.dart: aPlanNodetree and parsers for PostgreSQLEXPLAIN (FORMAT JSON), MySQLEXPLAIN FORMAT=JSON(nested loop of tables) and SQLiteEXPLAIN QUERY PLANrows. Each node has its own cost (cumulative cost minus its children's); the node with the largest own cost is highlighted (QueryPlanParser.hottest).explainTree; the base delegate returns none, so a driver without one keeps the text only.Plan | Textswitch. Plan draws the tree top-down with the hottest node outlined and each node's share of the cost as a bar. Text is the previous text plan.Not in this PR
PlanNode.details).EXPLAIN ANALYZEand its buffers (the issue asks for it behind an explicit action): not added.Not verified locally
Tests were not run locally, per the project rule.