You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sql-plan-replayer.md
+33-5Lines changed: 33 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -20,6 +20,8 @@ You can use `PLAN REPLAYER` to save the on-site information of a TiDB cluster. T
20
20
PLAN REPLAYER DUMP [WITH STATS AS OF TIMESTAMP expression] EXPLAIN [ANALYZE] sql-statement;
21
21
```
22
22
23
+
By default, TiDB stores files generated by `PLAN REPLAYER` in local storage. If you set [`tidb_cloud_storage_uri`](/system-variables.md#tidb_cloud_storage_uri-new-in-v740) to a valid external storage URI, TiDB stores the generated `ZIP` files in the specified storage. For supported URI formats, see [URI Formats of External Storage Services](/external-storage-uri.md).
24
+
23
25
Based on `sql-statement`, TiDB sorts out and exports the following on-site information:
24
26
25
27
- TiDB version
@@ -54,11 +56,14 @@ plan replayer dump with stats as of timestamp '2023-07-17 12:00:00' explain sele
54
56
plan replayer dump with stats as of timestamp'442012134592479233' explain select*from t;
55
57
```
56
58
57
-
`PLAN REPLAYER DUMP` packages the table information above into a `ZIP` file and returns the file identifier as the execution result.
59
+
`PLAN REPLAYER DUMP` packages the table information above into a `ZIP` file and returns the download information as the execution result:
60
+
61
+
- If the configured storage backend supports presigned URLs, TiDB returns a presigned URL.
62
+
- Otherwise, TiDB returns a file token.
58
63
59
64
> **Note:**
60
65
>
61
-
> The `ZIP` file is stored in a TiDB cluster for at most one hour. After one hour, TiDB will delete it.
66
+
> The result file is kept for at most one hour. After one hour, TiDB deletes it from the corresponding local or external storage.
62
67
63
68
```sql
64
69
MySQL [test]> plan replayer dump explain select*from t;
If the configured storage backend supports presigned URLs, the result returned by `PLAN REPLAYER DUMP` or `@@tidb_last_plan_replayer_token` is a presigned URL instead of a file token. For example:
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.
Because the file cannot be downloaded on MySQL Client, you need to use the TiDB HTTP interface and the file identifier to download the file:
130
+
If `PLAN REPLAYER DUMP` returns a presigned URL, you can use the URL directly to download the file:
131
+
132
+
{{< copyable "shell-regular" >}}
133
+
134
+
```shell
135
+
curl "${presigned_url}"> plan_replayer.zip
136
+
```
137
+
138
+
The presigned URL is valid for up to one hour.
139
+
140
+
If `PLAN REPLAYER DUMP` returns a file token, you need to use the TiDB HTTP interface and the file token to download the file:
115
141
116
142
{{< copyable "shell-regular" >}}
117
143
@@ -261,11 +287,13 @@ mysql> SELECT * FROM mysql.plan_replayer_status;
261
287
3 rows inset (0.00 sec)
262
288
```
263
289
264
-
The method of downloading the file of `PLAN REPLAYER CAPTURE` is the same as that of `PLAN REPLAYER`. For details, see [Examples of exporting cluster information](#examples-of-exporting-cluster-information).
290
+
If [`tidb_cloud_storage_uri`](/system-variables.md#tidb_cloud_storage_uri-new-in-v740) is configured, the captured file is also stored in the configured external storage. The `token` column still records the file token.
291
+
292
+
To download the file of `PLAN REPLAYER CAPTURE`, use the `token` value together with the TiDB HTTP interface. This is the same as the file-token based download flow described in [Examples of exporting cluster information](#examples-of-exporting-cluster-information).
265
293
266
294
> **Note:**
267
295
>
268
-
> The result file of `PLAN REPLAYER CAPTURE` is kept in the TiDB cluster for up to one week. After one week, TiDB deletes the file.
296
+
> The result file of `PLAN REPLAYER CAPTURE` is kept for up to one week. After one week, TiDB deletes it from the corresponding local or external storage.
Copy file name to clipboardExpand all lines: system-variables.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1725,10 +1725,11 @@ mysql> SELECT job_info FROM mysql.analyze_jobs ORDER BY end_time DESC LIMIT 1;
1725
1725
- Persists to cluster: Yes
1726
1726
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
1727
1727
- Default value: `""`
1728
-
- This variable is used to specify the Amazon S3 cloud storage URI to enable [Global Sort](/tidb-global-sort.md). After enabling the [TiDB Distributed eXecution Framework (DXF)](/tidb-distributed-execution-framework.md), you can use the Global Sort feature by configuring the URI and pointing it to an appropriate cloud storage path with the necessary permissions to access the storage. For more details, see [Amazon S3 URI format](/external-storage-uri.md#amazon-s3-uri-format).
1729
-
- The following statements can use the Global Sort feature.
1728
+
- This variable is used to specify the cloud storage URI for TiDB features that use external storage. After enabling the [TiDB Distributed eXecution Framework (DXF)](/tidb-distributed-execution-framework.md), you can use the [Global Sort](/tidb-global-sort.md) feature by configuring the URI and pointing it to an appropriate cloud storage path with the necessary permissions to access the storage. [`PLAN REPLAYER`](/sql-plan-replayer.md) also uses this URI to store the generated files. If this variable is empty, `PLAN REPLAYER` uses local storage. For URI formats, see [URI Formats of External Storage Services](/external-storage-uri.md).
1729
+
- The following statements or features can use this variable.
1730
1730
- The [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) statement.
1731
1731
- The [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) statement for import jobs.
1732
+
- [`PLAN REPLAYER`](/sql-plan-replayer.md), including files generated by `PLAN REPLAYER DUMP`, `PLAN REPLAYER CAPTURE`, and`PLAN REPLAYER CONTINUOUS CAPTURE`.
1732
1733
1733
1734
### tidb_ddl_error_count_limit
1734
1735
@@ -3701,7 +3702,7 @@ For a system upgraded to v5.0 from an earlier version, if you have not modified
3701
3702
- Scope: SESSION
3702
3703
- Applies to hint [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value): No
3703
3704
- Type: String
3704
-
- This variable is read-only and is used to obtain the result of the last `PLAN REPLAYER DUMP` execution in the current session.
3705
+
- This variable is read-only and is used to obtain the result of the last `PLAN REPLAYER DUMP` execution in the current session. The result is either a file token or, if the configured storage backend supports it, a presigned URL.
3705
3706
3706
3707
### tidb_load_based_replica_read_threshold <span class="version-mark">New in v7.0.0</span>
0 commit comments