From 012e9a1a402ae91fd6d91a1b569f9fcd0d8b88f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Mon, 4 Dec 2023 03:46:21 +0100 Subject: [PATCH 1/4] Update SHOW STATUS docs (#15363) --- TOC-tidb-cloud.md | 1 + TOC.md | 1 + sql-statements/sql-statement-flush-status.md | 3 +- sql-statements/sql-statement-show-status.md | 85 ++++++++++-------- status-variables.md | 92 ++++++++++++++++++++ system-variables.md | 2 +- 6 files changed, 146 insertions(+), 38 deletions(-) create mode 100644 status-variables.md diff --git a/TOC-tidb-cloud.md b/TOC-tidb-cloud.md index 6542d01852d56..5689917e2f6d7 100644 --- a/TOC-tidb-cloud.md +++ b/TOC-tidb-cloud.md @@ -580,6 +580,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 eca482a2d6762..a76edb220a1f2 100644 --- a/TOC.md +++ b/TOC.md @@ -648,6 +648,7 @@ - [Introduction](/tidb-distributed-execution-framework.md) - [TiDB Global Sort](/tidb-global-sort.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 0ed8003f33d87..619e4a703ef48 100644 --- a/sql-statements/sql-statement-flush-status.md +++ b/sql-statements/sql-statement-flush-status.md @@ -73,8 +73,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 a712396afc384..2afc118231350 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -5,56 +5,69 @@ summary: An overview of the usage of SHOW [GLOBAL|SESSION] STATUS for the TiDB d # 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:** +## Synopsis -![ShowTargetFilterable](/media/sqlgram/ShowTargetFilterable.png) +```ebnf+diagram +ShowStatusStmt ::= + 'SHOW' Scope? 'STATUS' ShowLikeOrWhere? -**GlobalScope:** +Scope ::= + ( 'GLOBAL' | 'SESSION' ) -![GlobalScope](/media/sqlgram/GlobalScope.png) +ShowLikeOrWhere ::= + "LIKE" SimpleExpr +| "WHERE" Expression +``` ## 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..4ecdf114fd93e --- /dev/null +++ b/status-variables.md @@ -0,0 +1,92 @@ +--- +title: Server Status Variables +summary: Use status variables to see the system and session status +--- + +# Server Status Variables + +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. + +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. + +Additionally, the [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) command is supported for 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 +- 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: Integer +- The TLS verification mode bitmask. + +### 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 +- Type: Timestamp +- The time and date of the last plan binding update. + +### server_id + +- Scope: SESSION | GLOBAL +- Type: String +- The UUID of the server. diff --git a/system-variables.md b/system-variables.md index 4857a09c92435..f34941f7d6fb6 100644 --- a/system-variables.md +++ b/system-variables.md @@ -49,7 +49,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 From 3bc068750002c8c7ea1385465bb5a9e2e37beda0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 29 Dec 2023 12:49:38 +0100 Subject: [PATCH 2/4] There are no compressions status vars in 7.5 --- status-variables.md | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/status-variables.md b/status-variables.md index 4ecdf114fd93e..1604de035f14a 100644 --- a/status-variables.md +++ b/status-variables.md @@ -13,24 +13,6 @@ Additionally, the [FLUSH STATUS](/sql-statements/sql-statement-flush-status.md) ## 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 -- Type: Integer -- The compression level that is used for the MySQL Protocol. - ### Ssl_cipher - Scope: SESSION | GLOBAL From 1df3b929d0e293d9d4e6ae6a52953d2a353cc867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Fri, 29 Dec 2023 12:52:24 +0100 Subject: [PATCH 3/4] Update output for 7.5 --- sql-statements/sql-statement-show-status.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/sql-statements/sql-statement-show-status.md b/sql-statements/sql-statement-show-status.md index 2afc118231350..1673ce248511f 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -30,9 +30,6 @@ mysql> SHOW SESSION STATUS; +-------------------------------+--------------------------------------+ | Variable_name | Value | +-------------------------------+--------------------------------------+ -| Compression | OFF | -| Compression_algorithm | | -| Compression_level | 0 | | Ssl_cipher | | | Ssl_cipher_list | | | Ssl_server_not_after | | @@ -44,7 +41,7 @@ mysql> SHOW SESSION STATUS; | 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) +10 rows in set (0.00 sec) sql> SHOW GLOBAL STATUS; +-----------------------+--------------------------------------+ From 7ca1e1cc113d118208b1f0ba2d41217aae165ac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Eeden?= Date: Tue, 16 Jan 2024 06:57:05 +0100 Subject: [PATCH 4/4] Update sql-statements/sql-statement-show-status.md Co-authored-by: Yasuo Honda --- sql-statements/sql-statement-show-status.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql-statements/sql-statement-show-status.md b/sql-statements/sql-statement-show-status.md index 1673ce248511f..9d88a21dd837c 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -43,7 +43,7 @@ mysql> SHOW SESSION STATUS; +-------------------------------+--------------------------------------+ 10 rows in set (0.00 sec) -sql> SHOW GLOBAL STATUS; +mysql> SHOW GLOBAL STATUS; +-----------------------+--------------------------------------+ | Variable_name | Value | +-----------------------+--------------------------------------+