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..9d88a21dd837c 100644 --- a/sql-statements/sql-statement-show-status.md +++ b/sql-statements/sql-statement-show-status.md @@ -5,56 +5,66 @@ 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 | ++-------------------------------+--------------------------------------+ +| 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 | ++-------------------------------+--------------------------------------+ +10 rows in set (0.00 sec) + +mysql> 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..1604de035f14a --- /dev/null +++ b/status-variables.md @@ -0,0 +1,74 @@ +--- +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 + +### 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