-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
69293: sql: implement a fast compressed logical plan mechanism r=rtaft,RaduBerinde a=cucaroach Implement a plan "gist" serializer piggy backing on the exec gen/explain factory infrastructure so that we can always know what the logical plan was and can do historical and statistical tracking. Logically its like an explain (SHAPE) but is even more stripped down. A gist is a sequence of bytes representing the flattened tree of operators and various operator specific metadata. The goal is to record every logical plan we use for every query to have historical data on which plans are used possibly linked up to statistics so we know which stats go with which logical plan. Also implement a decoder to turn the serialized plan back into a tree of explain.Node's that can be displayed using existing explain code. Currently this functionality is only exposed via a new EXPLAIN mode and via a crdb_internal "decoder" SRF. EXPLAIN (GIST) takes a query and returns a single string which is the encoded gist. crdb_internal.decode_plan_gist() takes an encoded gist string and writes out the logical plan one row per line. For performance numbers of the ExecBuild comparing a StubFactory to a PlanGistFactory wrapped around a StubFactory see the PR. Release note (sql change): Record compressed plan gist for all queries. For example, a query like this: SELECT * FROM abc UNION SELECT * FROM abc ORDER BY b,a Produces the following plan according to EXPLAIN (SHAPE) • distinct │ distinct on: a │ └── • union all │ ├── • sort │ │ order: +b,+a │ │ │ └── • scan │ missing stats │ table: abc@primary │ spans: FULL SCAN │ └── • sort │ order: +b,+a │ └── • scan missing stats table: abc@primary spans: FULL SCAN produces the following "gist": AgFuAgAHAAAAEQFuAgAHAAAAERANAAYGAA== The "gist" can be turned back into the following plan: • distinct │ distinct on │ └── • union all │ ├── • sort │ │ order │ │ │ └── • scan │ table: abc@primary │ spans: FULL SCAN │ └── • sort │ order │ └── • scan table: abc@primary spans: FULL SCAN Fixes: #63885 Co-authored-by: Tommy Reilly <[email protected]>
- Loading branch information
Showing
51 changed files
with
3,301 additions
and
252 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.