-
Notifications
You must be signed in to change notification settings - Fork 708
planner: Plan Replayer supports dumping multiple statement at once #22429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
qw4990
wants to merge
1
commit into
pingcap:master
Choose a base branch
from
qw4990:pr-66162
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -18,9 +18,10 @@ You can use `PLAN REPLAYER` to save the on-site information of a TiDB cluster. T | |||||
|
|
||||||
| ```sql | ||||||
| PLAN REPLAYER DUMP [WITH STATS AS OF TIMESTAMP expression] EXPLAIN [ANALYZE] sql-statement; | ||||||
| PLAN REPLAYER DUMP EXPLAIN [ANALYZE] ( 'sql1', 'sql2', ... ); | ||||||
| ``` | ||||||
|
|
||||||
| Based on `sql-statement`, TiDB sorts out and exports the following on-site information: | ||||||
| Based on the SQL statement or statements, TiDB sorts out and exports the following on-site information: | ||||||
|
|
||||||
| - TiDB version | ||||||
| - TiDB configuration | ||||||
|
|
@@ -31,6 +32,11 @@ Based on `sql-statement`, TiDB sorts out and exports the following on-site infor | |||||
| - The result of `EXPLAIN [ANALYZE] sql-statement` | ||||||
| - Some internal procedures of query optimization | ||||||
|
|
||||||
| Depending on whether you dump a single SQL statement or multiple SQL statements, the structure of the exported ZIP file is as follows: | ||||||
|
|
||||||
| - For a single SQL statement, the ZIP file includes `sql/sql0.sql` and `explain.txt`. | ||||||
| - For multiple SQL statements, the ZIP file includes `sql/sql0.sql`, `sql/sql1.sql`, ... and the corresponding `explain/explain0.txt`, `explain/explain1.txt`, ..., together with schema and statistics files for the referenced tables. | ||||||
|
|
||||||
| If historical statistics are [enabled](/system-variables.md#tidb_enable_historical_stats), you can specify a time in the `PLAN REPLAYER` statement to get the historical statistics for the corresponding time. You can directly specify a time and date or specify a timestamp. TiDB looks for the historical statistics before the specified time and exports the latest one among them. | ||||||
|
|
||||||
| If there are no historical statistics before the specified time, TiDB exports the latest statistics, which is consistent with the behavior when no time is specified. In addition, TiDB prints the error messages in the `errors.txt` file within the exported `ZIP` file. | ||||||
|
|
@@ -88,7 +94,18 @@ SELECT @@tidb_last_plan_replayer_token; | |||||
| 1 row in set (0.00 sec) | ||||||
| ``` | ||||||
|
|
||||||
| When there are multiple SQL statements, you can obtain the result of the `PLAN REPLAYER DUMP` execution using a file. The results of multiple SQL statements are separated by `;` in this file. | ||||||
| To dump multiple SQL statements in a single command, you can use the multi-statement syntax: | ||||||
|
|
||||||
| {{< copyable "sql" >}} | ||||||
|
|
||||||
| ```sql | ||||||
| PLAN REPLAYER DUMP EXPLAIN ( | ||||||
| 'SELECT * FROM t WHERE a = 1', | ||||||
| 'SELECT * FROM t WHERE b > 1' | ||||||
| ); | ||||||
| ``` | ||||||
|
|
||||||
| Alternatively, when there are multiple SQL statements, you can obtain the result of the `PLAN REPLAYER DUMP` execution using a file. The results of multiple SQL statements are separated by `;` in this file. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sentence can be simplified for better readability and to be more direct for the user, in line with the style guide's preference for using the second person ('you').
Suggested change
References
|
||||||
|
|
||||||
| ```sql | ||||||
| plan replayer dump explain 'sqls.txt'; | ||||||
|
|
||||||
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To improve clarity, this section can be rephrased to be more direct and avoid using '...'.
References