Skip to content

DM-55975: Czar-level EXPLAIN support for xrd branch - #1089

Open
malensek wants to merge 6 commits into
xrdfrom
tickets/DM-55975
Open

DM-55975: Czar-level EXPLAIN support for xrd branch#1089
malensek wants to merge 6 commits into
xrdfrom
tickets/DM-55975

Conversation

@malensek

Copy link
Copy Markdown
Member

This is based on #1086, and adds EXPLAIN support to the xrd branch.

It is largely similar to the version for main, but previously, ScanTableInfo was shared across the query and dispatch layers, which was the source of some recent conflicts between these branches. A new query::ScanTableInfo was added to separate concerns between these sets of modules, and a few helper functions were also added to provide EXPLAIN with needed metadata.

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.
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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds czar-level EXPLAIN support for SELECT queries on the xrd branch.

Changes:

  • Adds traditional and JSON EXPLAIN parsing and result generation.
  • Separates query-layer scan metadata from dispatch metadata.
  • Reuses chunk analysis for SELECT and EXPLAIN paths.

Reviewed changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
src/query/ScanTableInfo.h Defines query-layer scan metadata.
src/query/QueryContext.h Uses query-layer scan metadata.
src/qproc/QuerySession.h Exposes chunk and scan analysis APIs.
src/qproc/QuerySession.cc Implements reusable chunk setup and metadata conversion.
src/qana/ScanTablePlugin.h Adopts query-layer scan types.
src/qana/ScanTablePlugin.cc Populates query scan metadata.
src/proxy/test.sh Adds proxy EXPLAIN commands.
src/proxy/mysqlProxy.lua Allows EXPLAIN forwarding.
src/proto/ScanTableInfo.h Converts query metadata for dispatch.
src/css/ScanTableParams.h Updates scan-rating documentation.
src/ccontrol/UserQueryType.h Declares EXPLAIN recognition.
src/ccontrol/UserQueryType.cc Parses EXPLAIN formats.
src/ccontrol/UserQuerySelect.cc Delegates chunk setup to QuerySession.
src/ccontrol/UserQueryFactory.cc Builds and routes EXPLAIN queries.
src/ccontrol/UserQueryExplain.h Defines the EXPLAIN query implementation.
src/ccontrol/UserQueryExplain.cc Produces tabular or JSON results.
src/ccontrol/testUserQueryType.cc Tests EXPLAIN classification.
src/ccontrol/CMakeLists.txt Builds the new implementation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/proxy/test.sh
Comment on lines +37 to +38
mysql --port=4040 --protocol=TCP proxyTest -e "explain select * from Obj"
mysql --port=4040 --protocol=TCP proxyTest -e "explain format=json select * from Obj"

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My understanding is that script is just there for manual checking, not really part of integration coverage. But someone please correct me if I am wrong!

@malensek
malensek marked this pull request as ready for review August 28, 2026 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants