DM-55571: Czar-level EXPLAIN query support - #1086
Open
malensek wants to merge 6 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds czar-side EXPLAIN support without dispatching worker jobs.
Changes:
- Parses traditional and JSON EXPLAIN syntax.
- Computes query plans, restrictors, chunk coverage, and scan metadata.
- Returns analysis through temporary result tables.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/qproc/QuerySession.h |
Exposes chunk setup. |
src/qproc/QuerySession.cc |
Centralizes chunk computation. |
src/proxy/test.sh |
Adds EXPLAIN smoke tests. |
src/proxy/mysqlProxy.lua |
Allows EXPLAIN routing. |
src/ccontrol/UserQueryType.h |
Declares EXPLAIN detection. |
src/ccontrol/UserQueryType.cc |
Parses EXPLAIN syntax. |
src/ccontrol/UserQuerySelect.cc |
Uses shared chunk setup. |
src/ccontrol/UserQueryFactory.cc |
Creates EXPLAIN queries. |
src/ccontrol/UserQueryExplain.h |
Defines the EXPLAIN query type. |
src/ccontrol/UserQueryExplain.cc |
Produces tabular or JSON reports. |
src/ccontrol/testUserQueryType.cc |
Tests EXPLAIN recognition. |
src/ccontrol/CMakeLists.txt |
Builds new implementation. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+231
to
+233
| try { | ||
| // Compute chunk coverage | ||
| qs->setupChunking(sharedResources->secondaryIndex); |
Member
Author
There was a problem hiding this comment.
Nice catch, Copilot! That will call applyFinal on all the plugins... and it's a no-op on all but one, ScanTablePlugin! 👍
malensek
force-pushed
the
tickets/DM-55571
branch
2 times, most recently
from
August 25, 2026 04:48
a1783cb to
b2be30c
Compare
Each of these isX() helper functions are called by UserQueryFactory (sometimes multiple calls) and carried a TRACE-level log that resulted in the function name and query string being printed repeatedly. Since the information is already printed at the DEBUG level (both the query string and how it ends up being handled), these can be safely removed.
malensek
force-pushed
the
tickets/DM-55571
branch
from
August 27, 2026 18:50
b2be30c to
f0967ea
Compare
ScanTableInfo was previously used on both sides of the aisle between the front-end query analysis layer and the back-end worker dispatch. This separates them into two distinct versions to avoid dependencies reaching across the aisle.
This chunk coverage computation already relied on several parts of QuerySession, and relocating it allows us to use it both during construction of SELECT queries as well as EXPLAIN queries.
This includes a new query type for czar-level EXPLAIN support and the required plumbing to execute it. Since this version of EXPLAIN only runs on the czar, it calculates a variety of query information accessible there, such as the scan rating and number of chunks that will be involved in the query being analyzed. Note that this does *NOT* dispatch EXPLAIN queries to the workers for analysis downstream from the czar.
These tests exercise the syntax surrounding EXPLAIN queries, which is handled in UserQueryFactory and detected via regex.
malensek
force-pushed
the
tickets/DM-55571
branch
from
August 27, 2026 19:50
f0967ea to
1dff372
Compare
malensek
marked this pull request as ready for review
August 28, 2026 22:38
fritzm
approved these changes
Aug 30, 2026
fritzm
left a comment
Contributor
There was a problem hiding this comment.
Looks good to me -- thanks!
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.
This adds support for
EXPLAIN <query>that runs at the czar to analyze queries before they execute. This could be particularly useful in situations where a user wants to understand how their query is being scheduled, how complex it is, or how much time it may take to execute.Currently, the following information is reported:
JSON support is also available via
EXPLAIN FORMAT=JSON <query>Known limitations:
EXPLAINqueries to workers and collect all of the results into a single comprehensive report. If this incurs too much additional latency, we could support both "shallow" and "deep" variants, or something likeEXPLAIN FULL <query>. There is no standardized spec forEXPLAINbehavior so we have some flexibility here.SELECT COUNT(*). One possible workaround is directly executingSELECTqueries to their fullest extent and capturing the information there instead of registering a new query type.This PR will currently not merge cleanly on the. Partially resolved by adding a new query-onlyxrdbranch, undergoing investigation...ScanTableInfoto separate concerns between the query/frontend and backend layers. The rest of the minor tweaks went to a separate PR.Testing:
Gives us: