From 9aa3a70d879806d30948c7036d6ed55e609cb613 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 16 Nov 2023 17:21:28 +0100 Subject: [PATCH 1/7] Update SHOW STATUS docs --- TOC-tidb-cloud.md | 1 + TOC.md | 1 + sql-statements/sql-statement-flush-status.md | 3 +- sql-statements/sql-statement-show-status.md | 83 ++++++++++-------- status-variables.md | 91 ++++++++++++++++++++ 5 files changed, 141 insertions(+), 38 deletions(-) create mode 100644 status-variables.md diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index f44ecfee672c1..bc047176b571f 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -576,6 +576,7 @@ - [Metadata Lock](/metadata-lock.md) - [Use UUIDs](/best-practices/uuid.md) - [System Variables](/system-variables.md) + - [Server Status Variables](/status-variables.md) - Storage Engines - TiKV - [TiKV Overview](/tikv-overview.md) diff --git a/TOC.md b/TOC.md index f83b17bb98b91..41829dcfde931 100644 --- a/TOC.md +++ b/TOC.md @@ -643,6 +643,7 @@ - [Compatibility](/tiflash/tiflash-compatibility.md) - [Pipeline Execution Model](/tiflash/tiflash-pipeline-model.md) - [System Variables](/system-variables.md) + - [Server Status Variables](/status-variables.md) - Configuration File Parameters - [tidb-server](/tidb-configuration-file.md) - [tikv-server](/tikv-configuration-file.md) diff --git a/sql-statements/sql-statement-flush-status.md b/sql-statements/sql-statement-flush-status.md index a55a69bcec5c1..854f3160dbbb2 100644 --- a/sql-statements/sql-statement-flush-status.md +++ b/sql-statements/sql-statement-flush-status.md @@ -74,8 +74,9 @@ mysql> show status; ## MySQL compatibility -* This statement is included only for compatibility with MySQL. +* This statement is compatible with MySQL. ## See also * [SHOW \[GLOBAL|SESSION\] STATUS](/sql-statements/sql-statement-show-status.md) +* [Server Status Variables](/status-variables.md) diff --git a/sql-statements/sql-statement-show-status.md b/sql-statements/sql-statement-show-status.md index 21ea4c7dc538e..e8a0e409f9f3c 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -6,56 +6,65 @@ aliases: ['/docs/dev/sql-statements/sql-statement-show-status/','/docs/dev/refer # SHOW [GLOBAL|SESSION] STATUS -This statement is included for compatibility with MySQL. It has no effect on TiDB, which uses Prometheus and Grafana for centralized metrics collection instead of `SHOW STATUS`. +This statement is included for compatibility with MySQL. TiDB uses Prometheus and Grafana for centralized metrics collection instead of `SHOW STATUS` for most metrics. -## Synopsis - -**ShowStmt:** - -![ShowStmt](/media/sqlgram/ShowStmt.png) +A full description of the variables can be found here: [status variables](/status-variables.md) -**ShowTargetFilterable:** - -![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) +## Synopsis -**GlobalScope:** +```ebnf+diagram +ShowStatusStmt ::= + 'SHOW' GlobalScope STATUS -![GlobalScope](/media/sqlgram/GlobalScope.png) +GlobalScope ::= + ( 'GLOBAL' | 'SESSION' )? +``` ## Examples ```sql -mysql> show status; -+--------------------+--------------------------------------+ -| Variable_name | Value | -+--------------------+--------------------------------------+ -| Ssl_cipher_list | | -| server_id | 93e2e07d-6bb4-4a1b-90b7-e035fae154fe | -| ddl_schema_version | 141 | -| Ssl_verify_mode | 0 | -| Ssl_version | | -| Ssl_cipher | | -+--------------------+--------------------------------------+ -6 rows in set (0.01 sec) - -mysql> show global status; -+--------------------+--------------------------------------+ -| Variable_name | Value | -+--------------------+--------------------------------------+ -| Ssl_cipher | | -| Ssl_cipher_list | | -| Ssl_verify_mode | 0 | -| Ssl_version | | -| server_id | 93e2e07d-6bb4-4a1b-90b7-e035fae154fe | -| ddl_schema_version | 141 | -+--------------------+--------------------------------------+ -6 rows in set (0.00 sec) +mysql> SHOW SESSION STATUS; ++-------------------------------+--------------------------------------+ +| Variable_name | Value | ++-------------------------------+--------------------------------------+ +| Compression | OFF | +| Compression_algorithm | | +| Compression_level | 0 | +| Ssl_cipher | | +| Ssl_cipher_list | | +| Ssl_server_not_after | | +| Ssl_server_not_before | | +| Ssl_verify_mode | 0 | +| Ssl_version | | +| Uptime | 1409 | +| ddl_schema_version | 116 | +| last_plan_binding_update_time | 0000-00-00 00:00:00 | +| server_id | 61160e73-ab80-40ff-8f33-27d55d475fd1 | ++-------------------------------+--------------------------------------+ +13 rows in set (0.00 sec) + +sql> SHOW GLOBAL STATUS; ++-----------------------+--------------------------------------+ +| Variable_name | Value | ++-----------------------+--------------------------------------+ +| Ssl_cipher | | +| Ssl_cipher_list | | +| Ssl_server_not_after | | +| Ssl_server_not_before | | +| Ssl_verify_mode | 0 | +| Ssl_version | | +| Uptime | 1413 | +| ddl_schema_version | 116 | +| server_id | 61160e73-ab80-40ff-8f33-27d55d475fd1 | ++-----------------------+--------------------------------------+ +9 rows in set (0.00 sec) ``` ## MySQL compatibility -* This statement is included only for compatibility with MySQL. +* This statement is compatible with MySQL. ## See also * [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) +* [Server Status Variables](/status-variables.md) diff --git a/status-variables.md b/status-variables.md new file mode 100644 index 0000000000000..7529f07bac59a --- /dev/null +++ b/status-variables.md @@ -0,0 +1,91 @@ +--- +title: Server Status Variables +summary: Use status variables to see the system and session status +--- + +# Server Status Variables + +Most status variables are implemented to be compatible with MySQL. These variables give information about the global status of the server and the status of the current session. + +The [SHOW GLOBAL STATUS](/sql-statements/sql-statement-show-status.md) command can be used to retrieve the global status and the [SHOW SESSION STATUS](/sql-statements/sql-statement-show-status.md) command can be used to see the status of the current session. + +The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is also support to aid MySQL compatibility. + +## Variable Reference + +### Compression + +- Scope: SESSION +- Type: Boolean +- Indicates if the MySQL Protocol uses compression or not. + +### Compression_algorithm + +- Scope: SESSION +- Type: String +- Indicates the compression algorithm that is used for the MySQL Protocol. + +### Compression_level + +- Scope: SESSION | GLOBAL +- Type: Integer +- The compression level that is used for the MySQL Protocol. + +### Ssl_cipher + +- Scope: SESSION | GLOBAL +- Type: String +- TLS Cipher that is in use. + +### Ssl_cipher_list + +- Scope: SESSION | GLOBAL +- Type: String +- The list of TLS Ciphers that the server supports. + +### Ssl_server_not_after + +- Scope: SESSION | GLOBAL +- Type: Date +- The expiration date of the X.509 certificate of the server that is used for TLS connections. + +### Ssl_server_not_before + +- Scope: SESSION | GLOBAL +- Type: String +- The start date of the X.509 certificate of the server that is used for TLS connections. + +### Ssl_verify_mode + +- Scope: SESSION | GLOBAL +- Type: String + +### Ssl_version + +- Scope: SESSION | GLOBAL +- Type: String +- The version of the TLS protocol that is used + +### Uptime + +- Scope: SESSION | GLOBAL +- Type: Integer +- Uptime of the server in seconds. + +### ddl_schema_version + +- Scope: SESSION | GLOBAL +- Type: Integer +- The version of the DDL schema that is used. + +### last_plan_binding_update_time New in v5.2.0 + +- Scope: SESSION | GLOBAL +- Type: Timestamp +- The time and date of the last plan binding update. + +### server_id + +- Scope: SESSION | GLOBAL +- Type: String +- UUID of the server From 6599204b71436c946958c80a150c952a617d6120 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 16 Nov 2023 17:26:40 +0100 Subject: [PATCH 2/7] update --- status-variables.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/status-variables.md b/status-variables.md index 7529f07bac59a..f44ed7853a47e 100644 --- a/status-variables.md +++ b/status-variables.md @@ -58,7 +58,8 @@ The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is als ### Ssl_verify_mode - Scope: SESSION | GLOBAL -- Type: String +- Type: Integer +- The TLS verification mode bitmask. ### Ssl_version From c7a00e395d65938bf79a04f8e88dbc635bf8ea40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 16 Nov 2023 17:34:47 +0100 Subject: [PATCH 3/7] update show status ebnf --- sql-statements/sql-statement-show-status.md | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/sql-statements/sql-statement-show-status.md b/sql-statements/sql-statement-show-status.md index e8a0e409f9f3c..269befdc45b59 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -14,10 +14,14 @@ A full description of the variables can be found here: [status variables](/statu ```ebnf+diagram ShowStatusStmt ::= - 'SHOW' GlobalScope STATUS + 'SHOW' Scope? 'STATUS' ShowLikeOrWhere? -GlobalScope ::= - ( 'GLOBAL' | 'SESSION' )? +Scope ::= + ( 'GLOBAL' | 'SESSION' ) + +ShowLikeOrWhere ::= + "LIKE" SimpleExpr +| "WHERE" Expression ``` ## Examples From 5820f655ff976d8e4d9b7324d211133f651e8160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 20 Nov 2023 07:40:46 +0100 Subject: [PATCH 4/7] Correct scope based on review --- status-variables.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/status-variables.md b/status-variables.md index f44ed7853a47e..cdfc92b789be7 100644 --- a/status-variables.md +++ b/status-variables.md @@ -27,7 +27,7 @@ The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is als ### Compression_level -- Scope: SESSION | GLOBAL +- Scope: SESSION - Type: Integer - The compression level that is used for the MySQL Protocol. @@ -81,7 +81,7 @@ The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is als ### last_plan_binding_update_time New in v5.2.0 -- Scope: SESSION | GLOBAL +- Scope: SESSION - Type: Timestamp - The time and date of the last plan binding update. From b8cf8ac5f1868b131262027b00a740bf7ab53089 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Wed, 22 Nov 2023 09:11:06 +0100 Subject: [PATCH 5/7] Apply suggestions from code review Co-authored-by: Ran --- status-variables.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/status-variables.md b/status-variables.md index cdfc92b789be7..5fd18ae8d0680 100644 --- a/status-variables.md +++ b/status-variables.md @@ -5,11 +5,11 @@ summary: Use status variables to see the system and session status # Server Status Variables -Most status variables are implemented to be compatible with MySQL. These variables give information about the global status of the server and the status of the current session. +Server status variables provide information about the global status of the server and the status of the current session in TiDB. Most of these variables are designed to be compatible with MySQL. -The [SHOW GLOBAL STATUS](/sql-statements/sql-statement-show-status.md) command can be used to retrieve the global status and the [SHOW SESSION STATUS](/sql-statements/sql-statement-show-status.md) command can be used to see the status of the current session. +You can retrieve the global status using the [SHOW GLOBAL STATUS](/sql-statements/sql-statement-show-status.md) command, and the status of the current session using the [SHOW SESSION STATUS](/sql-statements/sql-statement-show-status.md) command. -The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is also support to aid MySQL compatibility. +Additionally, the [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is supported for MySQL compatibility. ## Variable Reference @@ -89,4 +89,4 @@ The [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is als - Scope: SESSION | GLOBAL - Type: String -- UUID of the server +- The UUID of the server. From 5fa43a299bffcf09826c61bddf033dfd0b64b3c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 23 Nov 2023 08:05:50 +0100 Subject: [PATCH 6/7] Update status-variables.md Co-authored-by: Ran --- status-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/status-variables.md b/status-variables.md index 5fd18ae8d0680..4ecdf114fd93e 100644 --- a/status-variables.md +++ b/status-variables.md @@ -11,7 +11,7 @@ You can retrieve the global status using the [SHOW GLOBAL STATUS](/sql-statement Additionally, the [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is supported for MySQL compatibility. -## Variable Reference +## Variable reference ### Compression From 37a8e95c3938e2068db927c955fb1a43600bb0ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Thu, 23 Nov 2023 08:07:46 +0100 Subject: [PATCH 7/7] Fix style of 'Variable reference' --- system-variables.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/system-variables.md b/system-variables.md index cf05f2082609d..4de5c45d94158 100644 --- a/system-variables.md +++ b/system-variables.md @@ -50,7 +50,7 @@ Starting from v7.4.0, you can temporarily modify the value of some `SESSION` var For more information about the `SET_VAR` hint, see [SET_VAR](/optimizer-hints.md#set_varvar_namevar_value). -## Variable Reference +## Variable reference ### allow_auto_random_explicit_insert New in v4.0.3