Skip to content

planner: support explain [analyze] <plan_digest> for explain explore#61942

Merged
ti-chi-bot[bot] merged 6 commits intopingcap:masterfrom
qw4990:explain-analyze-plandigest
Jun 24, 2025
Merged

planner: support explain [analyze] <plan_digest> for explain explore#61942
ti-chi-bot[bot] merged 6 commits intopingcap:masterfrom
qw4990:explain-analyze-plandigest

Conversation

@qw4990
Copy link
Contributor

@qw4990 qw4990 commented Jun 23, 2025

What problem does this PR solve?

Issue Number: ref #60148

Problem Summary: planner: support explain [analyze] <plan_digest> for explain explore

What changed and how does it work?

Support explain [analyze] <plan_digest> for explain explore to make it easier to use.

An example is shown blow:

image

Changes:

  1. support the new syntax explain [analyze] <sql_digest>
  2. add 2 new columns in the output of explain explore
  3. fill necessary statement information for explain in getHintedStmtThroughPlanDigest

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jun 23, 2025
@tiprow
Copy link

tiprow bot commented Jun 23, 2025

Hi @qw4990. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@codecov
Copy link

codecov bot commented Jun 23, 2025

Codecov Report

Attention: Patch coverage is 71.42857% with 12 lines in your changes missing coverage. Please review.

Project coverage is 73.3842%. Comparing base (52ca7d4) to head (7d945a6).
Report is 1 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #61942        +/-   ##
================================================
+ Coverage   72.9715%   73.3842%   +0.4126%     
================================================
  Files          1735       1735                
  Lines        481907     482244       +337     
================================================
+ Hits         351655     353891      +2236     
+ Misses       108717     106809      -1908     
- Partials      21535      21544         +9     
Flag Coverage Δ
integration 42.3953% <7.6923%> (?)
unit 72.2072% <71.4285%> (-0.0095%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.7804% <ø> (ø)
parser ∅ <ø> (∅)
br 46.6387% <ø> (+0.0103%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@henrybw henrybw left a comment

Choose a reason for hiding this comment

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

LGTM, with one minor suggestion (feel free to take it or leave it).

fieldNames = []string{"statement", "binding_hint", "plan", "plan_digest", "avg_latency", "exec_times", "avg_scan_rows",
"avg_returned_rows", "latency_per_returned_row", "scan_rows_per_returned_row", "recommend", "reason"}
"avg_returned_rows", "latency_per_returned_row", "scan_rows_per_returned_row", "recommend", "reason",
"run_the_plan", "binding"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor issue, but maybe call this column explain_analyze instead of run_the_plan? run_the_plan is a bit awkward.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, I've updated this.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Jun 24, 2025
return err
}
if query == "" {
return errors.New("can't find any plans for '" + planDigest + "'")
Copy link
Member

Choose a reason for hiding this comment

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

It also can use NewNoStackError ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I've updated it.

@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Jun 24, 2025
@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 24, 2025

[LGTM Timeline notifier]

Timeline:

  • 2025-06-24 00:22:03.47823713 +0000 UTC m=+749576.201416104: ☑️ agreed by henrybw.
  • 2025-06-24 02:04:56.157334765 +0000 UTC m=+755748.880513759: ☑️ agreed by hawkingrei.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Jun 24, 2025

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hawkingrei, henrybw, tangenta, yudongusa

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Jun 24, 2025
@qw4990
Copy link
Contributor Author

qw4990 commented Jun 24, 2025

/test check-dev2

@tiprow
Copy link

tiprow bot commented Jun 24, 2025

@qw4990: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

Details

In response to this:

/test check-dev2

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot merged commit f28a1e2 into pingcap:master Jun 24, 2025
24 checks passed
morgo added a commit to morgo/tidb that referenced this pull request Jun 24, 2025
* origin/master: (129 commits)
  domain: Fix the issue that the min start ts doesn't correctly block keyspace-level GC (pingcap#61925)
  br: better control pd scheduler pause during log restore with filter (pingcap#61819)
  session: rename circuit breaker sysvar (pingcap#61951)
  dxfservice: create store for SYSTEM keyspace (pingcap#61752)
  docs: fix a dead link in CONTRIBUTORS.md (pingcap#61923)
  metrics/nextgengrafana: display keyspace separately (pingcap#61823)
  lightning: fix length check may be skipped for first line (pingcap#61874)
  planner: support `explain [analyze] <plan_digest>` for `explain explore` (pingcap#61942)
  planner: record explored plans into `tidb_statement_stats` when running `explain explore` (pingcap#61850)
  fix(runaway): ensure DistSQLContext's checker is synchronized with session variables (pingcap#61907)
  expression,planner: reuse the propOuterJoinConstSolver to improve performance (pingcap#61913)
  ddl,planner: remove unused and meaningless code (pingcap#61936)
  planner: remove unused field from physicalTableScan. (pingcap#61935)
  workload-learning: Extract metrics from cluster statements stats (pingcap#61378)
  executor: minor cleanup in builder.go (pingcap#61924)
  session: rename GetDomainInfoSchema to GetLatestInfoSchema (pingcap#61894)
  ingest: retry failed regions when batch scatter regions (pingcap#61722)
  planner: add tpch q1,q2,q3 benchmark (pingcap#61898)
  planner: fix uninit timeout for loading bindings (pingcap#61891)
  executor: report error when admin check on multiple tables (pingcap#61828)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants