From 73158cace91a8820346e4f83591fa1ba2f733faf Mon Sep 17 00:00:00 2001 From: wyx123654 <961871881@qq.com> Date: Wed, 22 Jan 2025 16:20:03 +0800 Subject: [PATCH 1/5] statments for session query --- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 68 ++-- .../session/queries/KILL-QUERY.md | 70 ++-- .../session/queries/SHOW-PROCESSLIST.md | 87 +++-- .../session/queries/SHOW-QUERY-STATS.md | 331 ++++++++++-------- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 69 ++-- .../session/queries/KILL-QUERY.md | 68 ++-- .../session/queries/SHOW-PROCESSLIST.md | 92 ++--- .../session/queries/SHOW-QUERY-STATS.md | 327 ++++++++--------- .../session/query/CLEAN-ALL-QUERY-STATS.md | 69 ++-- .../session/query/KILL-QUERY.md | 70 ++-- .../session/query/SHOW-PROCESSLIST.md | 91 ++--- .../session/query/SHOW-QUERY-STATS.md | 327 +++++++++-------- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 69 ++-- .../session/queries/KILL-QUERY.md | 68 ++-- .../session/queries/SHOW-PROCESSLIST.md | 92 ++--- .../session/queries/SHOW-QUERY-STATS.md | 327 ++++++++--------- .../session/query/CLEAN-ALL-QUERY-STATS.md | 67 ++-- .../session/query/KILL-QUERY.md | 73 ++-- .../session/query/SHOW-PROCESSLIST.md | 87 ++--- .../session/query/SHOW-QUERY-STATS.md | 326 +++++++++-------- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 68 ++-- .../session/queries/KILL-QUERY.md | 72 ++-- .../session/queries/SHOW-PROCESSLIST.md | 87 +++-- .../session/queries/SHOW-QUERY-STATS.md | 331 ++++++++++-------- 24 files changed, 1812 insertions(+), 1524 deletions(-) diff --git a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index aa4d621d9b060..560f01ba609b9 100644 --- a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -24,46 +24,64 @@ specific language governing permissions and limitations under the License. --> - - ## Description This statement is used to clear query statistics -grammar: +## Syntax ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -Remarks: +## Required Parameters + +**1. `ALL`** + +> ALL Clears all statistics + +**2. `DATABASE`** + +> DATABASE clears statistics of a database + +**3. `TABLE`** + +> TABLE Indicates that statistics of a table are cleared + +## Optional Parameters + +**1. ``** -1. If ALL is specified, all query statistics are cleared, including database and table, admin privilege is needed -2. If DATABASE is specified, the query statistics of the specified database are cleared, alter privilege for this database is needed -3. If TABLE is specified, the query statistics of the specified table are cleared, alter privilege for this table is needed +> If this parameter is set, the statistics of the corresponding database are cleared -## Example +**2. ``** -1. Clear all statistics -2. - ```sql - clean all query stats; - ``` +> If this parameter is set, the statistics of the corresponding table are cleared -2. Clear the specified database statistics - ```sql - clean database query stats for test_query_db; - ``` -3. Clear the specified table statistics +## Access Control Requirements - ```sql - clean table query stats from test_query_db.baseall; - ``` +The user who executes this SQL command must have at least the following permissions: -## Keywords +| Privilege | Object | Notes | +|:-------------|:---------|:--------------------------| +| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN | TABLE | If you specify a table, you need alter permission for that table | - CLEAN, QUERY, STATS -## Best Practice +## Examples + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` + diff --git a/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md index 9d834229cfbff..ad04531f15287 100644 --- a/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -24,62 +24,74 @@ specific language governing permissions and limitations under the License. --> +## Description +Each Doris connection runs in a separate thread. Use this statement to terminate the thread. -In Doris, each connection runs in a separate thread. You can terminate a thread using the `KILL processlist_id`statement. +## Syntax -The `processlist_id` for the thread can be found in the Id column from the SHOW PROCESSLIST output. Or you can use the `SELECT CONNECTION_ID()` command to query the current connection id. +```SQL +KILL [CONNECTION] +``` -Syntax: +## Varaint Syntax -```sql -KILL [CONNECTION] processlist_id +```SQL +KILL QUERY [ { | } ] ``` -## Kill query +## Required Parameters -You can also terminate the query command under execution based on the processlist_id or the query_id. +**1. ``** -Syntax: +> Indicates the ID of the connection thread that needs to be killed -```sql -KILL QUERY processlist_id | query_id -``` +**2. ``** + +> Indicates the ID of the query to be killed + +## Optional Parameters + +**1. `CONNECTION`** + +> Indicates whether the thread is currently connected + +## Usage Notes -## Example +- The thread process list identifier can be queried from the Id column output by the SHOW PROCESSLIST -1. Check the current connection id. +- The Connection ID can be queried from SELECT CONNECTION_ID() + +## Examples ```sql -mysql select connection_id(); +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -2. Check all connection id. - ```sql -mysql SHOW PROCESSLIST; +SHOW PROCESSLIST +``` + +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -3. Kill the currently running query, which will then be displayed as canceled. - ```sql -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) +kill 51 ``` - diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 35b1b93092413..0091f0641f89a 100644 --- a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -25,68 +25,65 @@ specific language governing permissions and limitations under the License. --> - - - ## Description -Display the running threads of the user. It should be noted that except the root user who can see all running threads, other users can only see their own running threads, and cannot see the running threads of other users. +Displays the thread that the user is running -Only display current connected FE's connection list by default, you can set session variable ```set show_all_fe_connection = true``` to show all FE's connection. - -grammar: +## Syntax ```sql SHOW [FULL] PROCESSLIST ``` -illustrate: - -- CurrentConnected: Indicates whether the connection is currently connected -- Id: It is the unique identifier of this thread. When we find that there is a problem with this thread, we can use the kill command to add this Id value to kill this thread. -- User: refers to the user who started this thread. -- Host: Records the IP and port number of the client sending the request. Through this information, when troubleshooting the problem, we can locate which client and which process sent the request. -- LoginTime: Timestamp when the connection is make. -- Catalog: Catalog name. -- Db: which database the currently executed command is on. If no database is specified, the value is NULL . -- Command: refers to the command that the thread is executing at the moment. -- Time: Indicates the time the thread is in the current state. -- State: The state of the thread, corresponding to Command. -- QueryId: The ID of the current query statement. -- Info: Generally recorded is the statement executed by the thread. By default, only the first 100 characters are displayed, that is, the statement you see may be truncated. To see all the information, you need to use show full processlist. +## Optional Parameters -Common Command types are as follows: +**1. `FULL`** -- Query: The thread is executing a statement -- Sleep: is waiting for a client to send it an execute statement -- Quit: the thread is exiting -- Kill : The kill statement is being executed to kill the specified thread +> 表示是否查看其他用户的连接信息 -Other types can refer to [MySQL official website for explanation](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## Return Value -## Example +| column | Instructions | +|------------------|--------------------------------------| +| CurrentConnected | Whether the connection is current | +| Id | The unique identification of this thread | +| User | The user who started this thread | +| Host | The IP address and port number of the client sending the request are recorded | +| LoginTime | Time to establish a connection | +| Catalog | In which data directory is the command currently executed | +| Db | On which database is the command being executed? If no database is specified, the value is NULL | +| Command | The command that the thread is executing at this moment | +| Time | Time when the previous command is submitted to the current status, in seconds | +| State | State of thread | +| QueryId | ID of the current query statement | +| Info | Generally, the statement executed by the thread is recorded, and only the first 100 characters are displayed by default | -1. View the threads running by the current user +Common Command types are as follows: - ```SQL - SHOW PROCESSLIST - ``` +| column | Instructions | +| -- | -- | +| Query | The thread is executing a statement | +| Sleep | Waiting for the client to send it an execution statement | +| Quit | The thread is exiting | +| Kill | Executing the kill statement | - return +## Usage Notes - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` +In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. -## Keywords +## Examples - SHOW, PROCESSLIST +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` -## Best Practice diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 30939a5a45625..aefd55c491d81 100644 --- a/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -26,163 +26,184 @@ under the License. ## Description -This statement is used to show the query hit statistics of the database and table +This statement is used to display the database table columns hit by the historical query -grammar: +## Syntax ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; ``` -Remarks: - -1. Support query database and table history query hit statistics, restart fe after data will be reset, each fe separately statistics -2. Use FOR DATABASE and FROM TABLE to specify the query database or table hit statistics, respectively followed by the database name or table name -3. ALL can specify whether to display all index query hit statistics, VERBOSE can display more detailed hit statistics, these two parameters can be used separately, but must be placed at the end and can only be used on table queries -4. If no database is used, execute `SHOW QUERY STATS` directly to display the hit statistics of all databases -5. The result may have two columns: - QueryCount: The number of times the column was queried - FilterCount: The number of times the column was queried as a where condition -## Example - -1. Show the query hit statistics for `baseall` - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. Show the query hit statistics summary for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. Show the query hit statistics detail info for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. Show the query hit for a database - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. Show query hit statistics for all the databases - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## Keywords - - SHOW, QUERY, STATS; - -## Best Practice +## Optional Parameters + +**1. ``** + +> If this parameter is set, the matching information of the database is displayed + +**2. ``** + +> If this parameter is set, the matching status of a table is queried + +**3. `ALL`** + +> ALL Specifies whether to display the matching information of all indexes + +**4. `VERBOSE`** + +> VERBOSE displays detailed matching information + +## Usage Notes + +- Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. + +- You can use FOR DATABASE and FROM TABLE to specify the matching information of the database or table to be queried, followed by the database name or table name. + +- The ALL and VERBOSE parameters can be used alone or together, but they must be used last and only for table queries. + +- If no databases are being used, then simply executing 'SHOW QUERY STATS' will show the hits of all databases. + +- There may be two columns in the hit result: QueryCount indicates the number of times the column has been queried, and FilterCount indicates the number of times the column has been queried as the where condition. + +## Examples + +```sql +show query stats from baseall +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` + +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index f4abcd2ee3d1f..af3ef5923668b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -24,47 +24,64 @@ specific language governing permissions and limitations under the License. --> - - - ## 描述 -该语句用请空查询统计信息 +该语句用清空查询统计信息 -语法: +## 语法 ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -说明: +## 必选参数 -1. 如果指定 ALL,则清空所有查询统计信息,包括数据库和表的统计信息,需要 admin 权限 -2. 如果指定 DATABASE,则清空指定数据库的查询统计信息,需要对应 database 的 alter 权限 -3. 如果指定 TABLE,则清空指定表的查询统计信息,需要对应表的 alter 权限 +**1. `ALL`** -## 示例 +> ALL 可以清空所有统计信息 + +**2. `DATABASE`** + +> DATABASE 表示清空某个数据库的统计信息 + +**3. `TABLE`** + +> TABLE 表示清空某个表的统计信息 + +## 可选参数 + +**1. ``** + +> 若填写表示清空对应数据库的统计信息 -1. 清空所有统计信息 +**2. ``** - ```sql - clean all query stats; - ``` +> 若填写表示清空对应表的统计信息 -2. 清空指定数据库的统计信息 - ```sql - clean database query stats for test_query_db; - ``` -3. 清空指定表的统计信息 +## 权限控制 - ```sql - clean table query stats from test_query_db.baseall; - ``` +执行此 SQL 命令的用户必须至少具有以下权限: -## 关键词 +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:--------------------------| +| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | - CLEAN, QUERY, STATS -### 最佳实践 +## 示例 + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md index e2d092bbded0d..17dd8b749c567 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -26,58 +26,72 @@ under the License. ## 描述 -每个 Doris 的连接都在一个单独的线程中运行。您可以使用 KILL processlist_id 语句终止线程。 +每个 Doris 的连接都在一个单独的线程中运行。使用该语句终止线程。 -线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 或者 SELECT CONNECTION_ID() 来查询当前 Connection ID。 +## 语法 -语法: +```SQL +KILL [CONNECTION] +``` + +## 变种语法 ```SQL -KILL [CONNECTION] processlist_id +KILL QUERY [ { | } ] ``` +## 必选参数 -除此之外,您还可以使用 processlist_id 或者 query_id 终止正在执行的查询命令 +**1. ``** -语法: +> 表示需要被杀掉的连接线程 ID -```SQL -KILL QUERY processlist_id | query_id -``` +**2. ``** -## 示例 +> 表示需要被杀掉的查询 ID + +## 可选参数 + +**1. `CONNECTION`** + +> 表示是否是当前连接的线程 + +## 注意事项 -**1. 查看当前连接的 Connection ID。** +- 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 + +- Connection ID 可以从 SELECT CONNECTION_ID() 来查询 + +## 示例 ```sql -mysql select connection_id(); +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -**2. 查看所有连接的 Connection ID。** - ```sql -mysql SHOW PROCESSLIST; +SHOW PROCESSLIST +``` + +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -**3. 终止正在运行的查询,正在运行的查询会显示被取消。** - ```sql -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` \ No newline at end of file +kill 51 +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 9f8cae6a4d316..5ed3db5e86856 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -24,65 +24,65 @@ specific language governing permissions and limitations under the License. --> - -### Name - -SHOW PROCESSLIST - ## 描述 -显示用户正在运行的线程,需要注意的是,除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +显示用户正在运行的线程 -语法: +## 语法 ```sql SHOW [FULL] PROCESSLIST ``` -说明: - -- CurrentConnected: 是否为当前连接。 -- Id: 就是这个线程的唯一标识,当我们发现这个线程有问题的时候,可以通过 kill 命令,加上这个 Id 值将这个线程杀掉。 -- User: 就是指启动这个线程的用户。 -- Host: 记录了发送请求的客户端的 IP 和 端口号。通过这些信息在排查问题的时候,我们可以定位到是哪个客户端的哪个进程发送的请求。 -- LoginTime: 建立连接的时间。 -- Catalog: 当前执行的命令是在哪一个数据目录上。 -- Db: 当前执行的命令是在哪一个数据库上。如果没有指定数据库,则该值为 NULL。 -- Command: 是指此刻该线程正在执行的命令。 -- Time: 上一条命令提交到当前状态的时间,单位为秒。 -- State: 线程的状态,和 Command 对应。 -- QueryId: 当前查询语句的 ID。 -- Info: 一般记录的是线程执行的语句。默认只显示前 100 个字符,也就是你看到的语句可能是截断了的,要看全部信息,需要使用 show full processlist。 +## 可选参数 + +**1. `FULL`** + +> 表示是否查看其他用户的连接信息 + +## 返回值 + +| 列名 | 说明 | +| -- |--------------------------------------| +| CurrentConnected | 是否为当前连接 | +| Id | 这个线程的唯一标识 | +| User | 启动这个线程的用户 | +| Host | 记录了发送请求的客户端的 IP 和 端口号 | +| LoginTime | 建立连接的时间 | +| Catalog | 当前执行的命令是在哪一个数据目录上 | +| Db | 当前执行的命令是在哪一个数据库上,如果没有指定数据库,则该值为 NULL | +| Command | 此刻该线程正在执行的命令 | +| Time | 上一条命令提交到当前状态的时间,单位为秒 | +| State | 线程的状态 | +| QueryId | 当前查询语句的 ID | +| Info | 一般记录的是线程执行的语句,默认只显示前 100 个字符 | 常见的 Command 类型如下: -- Query: 该线程正在执行一个语句 -- Sleep: 正在等待客户端向它发送执行语句 -- Quit: 该线程正在退出 -- Kill : 正在执行 kill 语句,杀死指定线程 +| 列名 | 说明 | +| -- | -- | +| Query | 该线程正在执行一个语句 | +| Sleep | 正在等待客户端向它发送执行语句 | +| Quit | 该线程正在退出 | +| Kill | 正在执行 kill 语句 | -其他类型可以参考 [MySQL 官网解释](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## 注意事项 + +除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 ## 示例 -1. 查看当前用户正在运行的线程 - ```SQL - SHOW PROCESSLIST - ``` - 返回结果 - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` - -## 关键词 - - SHOW, PROCESSLIST - -### 最佳实践 +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 5ddda3bc2a84d..62342f8efd97d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -24,171 +24,186 @@ specific language governing permissions and limitations under the License. --> +## 描述 +该语句用于展示数据库中历史查询命中的库表列的情况 +## 语法 -### Name +```sql +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; +``` -SHOW QUERY STATS +## 可选参数 -## 描述 +**1. ``** -该语句用于展示数据库中历史查询命中的库表列的情况 +> 若填写表示展示数据库的命中情况 + +**2. ``** + +> 若填写表示查询某表的查询命中情况 + +**3. `ALL`** + +> ALL 可以指定是否展示所有 index 的查询命中情况 + +**4. `VERBOSE`** + +> VERBOSE 可以展示更详细的命中情况 + +## 注意事项 + +- 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 + +- 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名。 + +- ALL 和 VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用,也可以一起使用,但是必须放在最后 而且只能用在表的查询上。 + +- 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况。 + +- 命中结果中可能有两列:QueryCount 表示该列被查询次数,FilterCount 表示该列作为 where 条件被查询的次数。 + +## 示例 ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +show query stats from baseall ``` -说明: +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` -1. 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计 -2. 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名 -3. ALL 可以指定是否展示所有 index 的查询命中情况,VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用, - 也可以一起使用,但是必须放在最后 而且只能用在表的查询上 -4. 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况 -5. 命中结果中可能有两列: - QueryCount:该列被查询次数 - FilterCount: 该列作为 where 条件被查询的次数 -## 示例 +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` -1. 展示表`baseall` 的查询命中情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. 展示表的所物化视图的的命中的汇总情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. 展示表的所物化视图的的命中的详细情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. 展示数据库的命中情况 - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. 展示所有数据库的命中情况,这时不能 use 任何数据库 - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## 关键词 - - SHOW, QUERY, STATS; - -### 最佳实践 +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md index bcd327fc0b5f1..541609a9b0f70 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md @@ -24,47 +24,64 @@ specific language governing permissions and limitations under the License. --> - - - ## 描述 -该语句用请空查询统计信息 +该语句用清空查询统计信息 -语法: +## 语法 ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -说明: +## 必选参数 -1. 如果指定 ALL,则清空所有查询统计信息,包括数据库和表的统计信息,需要 admin 权限 -2. 如果指定 DATABASE,则清空指定数据库的查询统计信息,需要对应 database 的 alter 权限 -3. 如果指定 TABLE,则清空指定表的查询统计信息,需要对应表的 alter 权限 +**1. `ALL`** -## 示例 +> ALL 可以清空所有统计信息 + +**2. `DATABASE`** + +> DATABASE 表示清空某个数据库的统计信息 + +**3. `TABLE`** + +> TABLE 表示清空某个表的统计信息 + +## 可选参数 + +**1. ``** + +> 若填写表示清空对应数据库的统计信息 -1. 清空所有统计信息 +**2. ``** - ```sql - clean all query stats; - ``` +> 若填写表示清空对应表的统计信息 -2. 清空指定数据库的统计信息 - ```sql - clean database query stats for test_query_db; - ``` -3. 清空指定表的统计信息 +## 权限控制 - ```sql - clean table query stats from test_query_db.baseall; - ``` +执行此 SQL 命令的用户必须至少具有以下权限: -## 关键词 +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:--------------------------| +| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | - CLEAN, QUERY, STATS -## 最佳实践 +## 示例 + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md index da49b9fddcbff..17dd8b749c567 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md @@ -24,62 +24,74 @@ specific language governing permissions and limitations under the License. --> +## 描述 -## Kill 连接 +每个 Doris 的连接都在一个单独的线程中运行。使用该语句终止线程。 -每个 Doris 的连接都在一个单独的线程中运行。您可以使用 KILL processlist_id 语句终止线程。 +## 语法 -线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 或者 SELECT CONNECTION_ID() 来查询当前 Connection ID。 +```SQL +KILL [CONNECTION] +``` -语法: +## 变种语法 ```SQL -KILL [CONNECTION] processlist_id +KILL QUERY [ { | } ] ``` -## Kill 查询 +## 必选参数 -除此之外,您还可以使用 processlist_id 或者 query_id 终止正在执行的查询命令 +**1. ``** -语法: +> 表示需要被杀掉的连接线程 ID -```SQL -KILL QUERY processlist_id | query_id -``` +**2. ``** -## 示例 +> 表示需要被杀掉的查询 ID + +## 可选参数 + +**1. `CONNECTION`** + +> 表示是否是当前连接的线程 + +## 注意事项 + +- 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 -**1. 查看当前连接的 Connection ID。** +- Connection ID 可以从 SELECT CONNECTION_ID() 来查询 + +## 示例 ```sql -mysql select connection_id(); +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -**2. 查看所有连接的 Connection ID。** - ```sql -mysql SHOW PROCESSLIST; +SHOW PROCESSLIST +``` + +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -**3. 终止正在运行的查询,正在运行的查询会显示被取消。** - ```sql -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` \ No newline at end of file +kill 51 +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index dcb2ffc9135c6..5ed3db5e86856 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -24,64 +24,65 @@ specific language governing permissions and limitations under the License. --> - - ## 描述 -显示用户正在运行的线程,需要注意的是,除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +显示用户正在运行的线程 -默认只限制当前连接的 FE 的连接列表,可以通过设置 session 变量```set show_all_fe_connection = true```来查看所有 FE 的连接 - -语法: +## 语法 ```sql SHOW [FULL] PROCESSLIST ``` -说明: - -- CurrentConnected: 是否为当前连接。 -- Id: 就是这个线程的唯一标识,当我们发现这个线程有问题的时候,可以通过 kill 命令,加上这个 Id 值将这个线程杀掉。 -- User: 就是指启动这个线程的用户。 -- Host: 记录了发送请求的客户端的 IP 和 端口号。通过这些信息在排查问题的时候,我们可以定位到是哪个客户端的哪个进程发送的请求。 -- LoginTime: 建立连接的时间。 -- Catalog: 当前执行的命令是在哪一个数据目录上。 -- Db: 当前执行的命令是在哪一个数据库上。如果没有指定数据库,则该值为 NULL。 -- Command: 是指此刻该线程正在执行的命令。 -- Time: 上一条命令提交到当前状态的时间,单位为秒。 -- State: 线程的状态,和 Command 对应。 -- QueryId: 当前查询语句的 ID。 -- Info: 一般记录的是线程执行的语句。默认只显示前 100 个字符,也就是你看到的语句可能是截断了的,要看全部信息,需要使用 show full processlist。 +## 可选参数 + +**1. `FULL`** + +> 表示是否查看其他用户的连接信息 + +## 返回值 + +| 列名 | 说明 | +| -- |--------------------------------------| +| CurrentConnected | 是否为当前连接 | +| Id | 这个线程的唯一标识 | +| User | 启动这个线程的用户 | +| Host | 记录了发送请求的客户端的 IP 和 端口号 | +| LoginTime | 建立连接的时间 | +| Catalog | 当前执行的命令是在哪一个数据目录上 | +| Db | 当前执行的命令是在哪一个数据库上,如果没有指定数据库,则该值为 NULL | +| Command | 此刻该线程正在执行的命令 | +| Time | 上一条命令提交到当前状态的时间,单位为秒 | +| State | 线程的状态 | +| QueryId | 当前查询语句的 ID | +| Info | 一般记录的是线程执行的语句,默认只显示前 100 个字符 | 常见的 Command 类型如下: -- Query: 该线程正在执行一个语句 -- Sleep: 正在等待客户端向它发送执行语句 -- Quit: 该线程正在退出 -- Kill : 正在执行 kill 语句,杀死指定线程 +| 列名 | 说明 | +| -- | -- | +| Query | 该线程正在执行一个语句 | +| Sleep | 正在等待客户端向它发送执行语句 | +| Quit | 该线程正在退出 | +| Kill | 正在执行 kill 语句 | -其他类型可以参考 [MySQL 官网解释](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## 注意事项 + +除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 ## 示例 -1. 查看当前用户正在运行的线程 - ```SQL - SHOW PROCESSLIST - ``` - 返回结果 - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` - -## 关键词 - - SHOW, PROCESSLIST - -## 最佳实践 +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md index f7162a1d8668b..62342f8efd97d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md @@ -24,167 +24,186 @@ specific language governing permissions and limitations under the License. --> - - - ## 描述 该语句用于展示数据库中历史查询命中的库表列的情况 +## 语法 + ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; ``` -说明: +## 可选参数 + +**1. ``** + +> 若填写表示展示数据库的命中情况 + +**2. ``** + +> 若填写表示查询某表的查询命中情况 + +**3. `ALL`** + +> ALL 可以指定是否展示所有 index 的查询命中情况 + +**4. `VERBOSE`** + +> VERBOSE 可以展示更详细的命中情况 + +## 注意事项 + +- 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 + +- 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名。 + +- ALL 和 VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用,也可以一起使用,但是必须放在最后 而且只能用在表的查询上。 + +- 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况。 + +- 命中结果中可能有两列:QueryCount 表示该列被查询次数,FilterCount 表示该列作为 where 条件被查询的次数。 -1. 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计 -2. 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名 -3. ALL 可以指定是否展示所有 index 的查询命中情况,VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用, - 也可以一起使用,但是必须放在最后 而且只能用在表的查询上 -4. 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况 -5. 命中结果中可能有两列: - QueryCount:该列被查询次数 - FilterCount: 该列作为 where 条件被查询的次数 ## 示例 -1. 展示表`baseall` 的查询命中情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. 展示表的所物化视图的的命中的汇总情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. 展示表的所物化视图的的命中的详细情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. 展示数据库的命中情况 - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. 展示所有数据库的命中情况,这时不能 use 任何数据库 - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## 关键词 - - SHOW, QUERY, STATS; - -## 最佳实践 +```sql +show query stats from baseall +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` + +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index f4abcd2ee3d1f..af3ef5923668b 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -24,47 +24,64 @@ specific language governing permissions and limitations under the License. --> - - - ## 描述 -该语句用请空查询统计信息 +该语句用清空查询统计信息 -语法: +## 语法 ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -说明: +## 必选参数 -1. 如果指定 ALL,则清空所有查询统计信息,包括数据库和表的统计信息,需要 admin 权限 -2. 如果指定 DATABASE,则清空指定数据库的查询统计信息,需要对应 database 的 alter 权限 -3. 如果指定 TABLE,则清空指定表的查询统计信息,需要对应表的 alter 权限 +**1. `ALL`** -## 示例 +> ALL 可以清空所有统计信息 + +**2. `DATABASE`** + +> DATABASE 表示清空某个数据库的统计信息 + +**3. `TABLE`** + +> TABLE 表示清空某个表的统计信息 + +## 可选参数 + +**1. ``** + +> 若填写表示清空对应数据库的统计信息 -1. 清空所有统计信息 +**2. ``** - ```sql - clean all query stats; - ``` +> 若填写表示清空对应表的统计信息 -2. 清空指定数据库的统计信息 - ```sql - clean database query stats for test_query_db; - ``` -3. 清空指定表的统计信息 +## 权限控制 - ```sql - clean table query stats from test_query_db.baseall; - ``` +执行此 SQL 命令的用户必须至少具有以下权限: -## 关键词 +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:--------------------------| +| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | - CLEAN, QUERY, STATS -### 最佳实践 +## 示例 + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md index e2d092bbded0d..17dd8b749c567 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -26,58 +26,72 @@ under the License. ## 描述 -每个 Doris 的连接都在一个单独的线程中运行。您可以使用 KILL processlist_id 语句终止线程。 +每个 Doris 的连接都在一个单独的线程中运行。使用该语句终止线程。 -线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 或者 SELECT CONNECTION_ID() 来查询当前 Connection ID。 +## 语法 -语法: +```SQL +KILL [CONNECTION] +``` + +## 变种语法 ```SQL -KILL [CONNECTION] processlist_id +KILL QUERY [ { | } ] ``` +## 必选参数 -除此之外,您还可以使用 processlist_id 或者 query_id 终止正在执行的查询命令 +**1. ``** -语法: +> 表示需要被杀掉的连接线程 ID -```SQL -KILL QUERY processlist_id | query_id -``` +**2. ``** -## 示例 +> 表示需要被杀掉的查询 ID + +## 可选参数 + +**1. `CONNECTION`** + +> 表示是否是当前连接的线程 + +## 注意事项 -**1. 查看当前连接的 Connection ID。** +- 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 + +- Connection ID 可以从 SELECT CONNECTION_ID() 来查询 + +## 示例 ```sql -mysql select connection_id(); +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -**2. 查看所有连接的 Connection ID。** - ```sql -mysql SHOW PROCESSLIST; +SHOW PROCESSLIST +``` + +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -**3. 终止正在运行的查询,正在运行的查询会显示被取消。** - ```sql -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` \ No newline at end of file +kill 51 +``` diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 9f8cae6a4d316..5ed3db5e86856 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -24,65 +24,65 @@ specific language governing permissions and limitations under the License. --> - -### Name - -SHOW PROCESSLIST - ## 描述 -显示用户正在运行的线程,需要注意的是,除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +显示用户正在运行的线程 -语法: +## 语法 ```sql SHOW [FULL] PROCESSLIST ``` -说明: - -- CurrentConnected: 是否为当前连接。 -- Id: 就是这个线程的唯一标识,当我们发现这个线程有问题的时候,可以通过 kill 命令,加上这个 Id 值将这个线程杀掉。 -- User: 就是指启动这个线程的用户。 -- Host: 记录了发送请求的客户端的 IP 和 端口号。通过这些信息在排查问题的时候,我们可以定位到是哪个客户端的哪个进程发送的请求。 -- LoginTime: 建立连接的时间。 -- Catalog: 当前执行的命令是在哪一个数据目录上。 -- Db: 当前执行的命令是在哪一个数据库上。如果没有指定数据库,则该值为 NULL。 -- Command: 是指此刻该线程正在执行的命令。 -- Time: 上一条命令提交到当前状态的时间,单位为秒。 -- State: 线程的状态,和 Command 对应。 -- QueryId: 当前查询语句的 ID。 -- Info: 一般记录的是线程执行的语句。默认只显示前 100 个字符,也就是你看到的语句可能是截断了的,要看全部信息,需要使用 show full processlist。 +## 可选参数 + +**1. `FULL`** + +> 表示是否查看其他用户的连接信息 + +## 返回值 + +| 列名 | 说明 | +| -- |--------------------------------------| +| CurrentConnected | 是否为当前连接 | +| Id | 这个线程的唯一标识 | +| User | 启动这个线程的用户 | +| Host | 记录了发送请求的客户端的 IP 和 端口号 | +| LoginTime | 建立连接的时间 | +| Catalog | 当前执行的命令是在哪一个数据目录上 | +| Db | 当前执行的命令是在哪一个数据库上,如果没有指定数据库,则该值为 NULL | +| Command | 此刻该线程正在执行的命令 | +| Time | 上一条命令提交到当前状态的时间,单位为秒 | +| State | 线程的状态 | +| QueryId | 当前查询语句的 ID | +| Info | 一般记录的是线程执行的语句,默认只显示前 100 个字符 | 常见的 Command 类型如下: -- Query: 该线程正在执行一个语句 -- Sleep: 正在等待客户端向它发送执行语句 -- Quit: 该线程正在退出 -- Kill : 正在执行 kill 语句,杀死指定线程 +| 列名 | 说明 | +| -- | -- | +| Query | 该线程正在执行一个语句 | +| Sleep | 正在等待客户端向它发送执行语句 | +| Quit | 该线程正在退出 | +| Kill | 正在执行 kill 语句 | -其他类型可以参考 [MySQL 官网解释](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## 注意事项 + +除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 ## 示例 -1. 查看当前用户正在运行的线程 - ```SQL - SHOW PROCESSLIST - ``` - 返回结果 - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` - -## 关键词 - - SHOW, PROCESSLIST - -### 最佳实践 +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` + diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 5ddda3bc2a84d..0334815f1f13a 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -24,171 +24,186 @@ specific language governing permissions and limitations under the License. --> +## 描述 +该语句用于展示数据库中历史查询命中的库表列的情况 +## 语法 -### Name +```sql +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; +``` -SHOW QUERY STATS +## 可选参数 -## 描述 +**1. ``** -该语句用于展示数据库中历史查询命中的库表列的情况 +> 若填写表示展示数据库的命中情况 + +**2. ``** + +> 若填写表示查询某表的查询命中情况 + +**3. `ALL`** + +> ALL 可以指定是否展示所有 index 的查询命中情况 + +**4. `VERBOSE`** + +> VERBOSE 可以展示更详细的命中情况 + +## 注意事项 + +- 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 + +- 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名。 + +- ALL 和 VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用,也可以一起使用,但是必须放在最后 而且只能用在表的查询上。 + +- 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况。 + +- 命中结果中可能有两列:QueryCount 表示该列被查询次数,FilterCount 表示该列作为 where 条件被查询的次数。 + +## 示例 ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +show query stats from baseall ``` -说明: +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` -1. 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计 -2. 通过 FOR DATABASE 和 FROM TABLE 可以指定查询数据库或者表的命中情况,后面分别接数据库名或者表名 -3. ALL 可以指定是否展示所有 index 的查询命中情况,VERBOSE 可以展示更详细的命中情况,这两个参数可以单独使用, - 也可以一起使用,但是必须放在最后 而且只能用在表的查询上 -4. 如果没有 use 任何数据库那么直接执行`SHOW QUERY STATS` 将展示所有数据库的命中情况 -5. 命中结果中可能有两列: - QueryCount:该列被查询次数 - FilterCount: 该列作为 where 条件被查询的次数 -## 示例 +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` -1. 展示表`baseall` 的查询命中情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. 展示表的所物化视图的的命中的汇总情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. 展示表的所物化视图的的命中的详细情况 - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. 展示数据库的命中情况 - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. 展示所有数据库的命中情况,这时不能 use 任何数据库 - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## 关键词 - - SHOW, QUERY, STATS; - -### 最佳实践 +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md index 82edee1183146..560f01ba609b9 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md @@ -24,45 +24,64 @@ specific language governing permissions and limitations under the License. --> - ## Description This statement is used to clear query statistics -grammar: +## Syntax ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -Remarks: +## Required Parameters -1. If ALL is specified, all query statistics are cleared, including database and table, admin privilege is needed -2. If DATABASE is specified, the query statistics of the specified database are cleared, alter privilege for this database is needed -3. If TABLE is specified, the query statistics of the specified table are cleared, alter privilege for this table is needed +**1. `ALL`** -## Examples +> ALL Clears all statistics + +**2. `DATABASE`** + +> DATABASE clears statistics of a database + +**3. `TABLE`** + +> TABLE Indicates that statistics of a table are cleared + +## Optional Parameters + +**1. ``** + +> If this parameter is set, the statistics of the corresponding database are cleared + +**2. ``** + +> If this parameter is set, the statistics of the corresponding table are cleared -1. Clear all statistics -2. - ```sql - clean all query stats; - ``` -2. Clear the specified database statistics +## Access Control Requirements - ```sql - clean database query stats for test_query_db; - ``` -3. Clear the specified table statistics +The user who executes this SQL command must have at least the following permissions: - ```sql - clean table query stats from test_query_db.baseall; - ``` +| Privilege | Object | Notes | +|:-------------|:---------|:--------------------------| +| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN | TABLE | If you specify a table, you need alter permission for that table | -## Keywords - CLEAN, QUERY, STATS +## Examples + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` -## Best Practice diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md index 958973300f538..ad04531f15287 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md @@ -24,63 +24,74 @@ specific language governing permissions and limitations under the License. --> - ## Description -In Doris, each connection runs in a separate thread. You can terminate a thread using the `KILL processlist_id`statement. +Each Doris connection runs in a separate thread. Use this statement to terminate the thread. -The `processlist_id` for the thread can be found in the Id column from the SHOW PROCESSLIST output. Or you can use the `SELECT CONNECTION_ID()` command to query the current connection id. +## Syntax -Syntax: +```SQL +KILL [CONNECTION] +``` + +## Varaint Syntax ```SQL -KILL [CONNECTION] processlist_id +KILL QUERY [ { | } ] ``` -## Kill query +## Required Parameters -You can also terminate the query command under execution based on the processlist_id or the query_id. +**1. ``** -Syntax: +> Indicates the ID of the connection thread that needs to be killed -```SQL -KILL QUERY processlist_id | query_id -``` +**2. ``** -## Example +> Indicates the ID of the query to be killed -1. Check the current connection id. +## Optional Parameters -```SQL -mysql select connection_id(); +**1. `CONNECTION`** + +> Indicates whether the thread is currently connected + +## Usage Notes + +- The thread process list identifier can be queried from the Id column output by the SHOW PROCESSLIST + +- The Connection ID can be queried from SELECT CONNECTION_ID() + +## Examples + +```sql +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -2. Check all connection id. +```sql +SHOW PROCESSLIST +``` -```SQL -mysql SHOW PROCESSLIST; +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -3. Kill the currently running query, which will then be displayed as canceled. - -```SQL -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) +```sql +kill 51 ``` - diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index 129bd79c6f821..8f65751a17dd5 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -24,64 +24,65 @@ specific language governing permissions and limitations under the License. --> - ## Description -Display the running threads of the user. It should be noted that except the root user who can see all running threads, other users can only see their own running threads, and cannot see the running threads of other users. - -Only display current connected FE's connection list by default, you can set session variable ```set show_all_fe_connection = true``` to show all FE's connection. +Displays the thread that the user is running -grammar: +## Syntax ```sql SHOW [FULL] PROCESSLIST ``` -illustrate: - -- CurrentConnected: Indicates whether the connection is currently connected -- Id: It is the unique identifier of this thread. When we find that there is a problem with this thread, we can use the kill command to add this Id value to kill this thread. -- User: refers to the user who started this thread. -- Host: Records the IP and port number of the client sending the request. Through this information, when troubleshooting the problem, we can locate which client and which process sent the request. -- LoginTime: Timestamp when the connection is make. -- Catalog: Catalog name. -- Db: which database the currently executed command is on. If no database is specified, the value is NULL . -- Command: refers to the command that the thread is executing at the moment. -- Time: Indicates the time the thread is in the current state. -- State: The state of the thread, corresponding to Command. -- QueryId: The ID of the current query statement. -- Info: Generally recorded is the statement executed by the thread. By default, only the first 100 characters are displayed, that is, the statement you see may be truncated. To see all the information, you need to use show full processlist. +## Optional Parameters -Common Command types are as follows: +**1. `FULL`** -- Query: The thread is executing a statement -- Sleep: is waiting for a client to send it an execute statement -- Quit: the thread is exiting -- Kill : The kill statement is being executed to kill the specified thread +> 表示是否查看其他用户的连接信息 -Other types can refer to [MySQL official website for explanation](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## Return Value -## Examples +| column | Instructions | +|------------------|--------------------------------------| +| CurrentConnected | Whether the connection is current | +| Id | The unique identification of this thread | +| User | The user who started this thread | +| Host | The IP address and port number of the client sending the request are recorded | +| LoginTime | Time to establish a connection | +| Catalog | In which data directory is the command currently executed | +| Db | On which database is the command being executed? If no database is specified, the value is NULL | +| Command | The command that the thread is executing at this moment | +| Time | Time when the previous command is submitted to the current status, in seconds | +| State | State of thread | +| QueryId | ID of the current query statement | +| Info | Generally, the statement executed by the thread is recorded, and only the first 100 characters are displayed by default | + +Common Command types are as follows: -1. View the threads running by the current user +| column | Instructions | +| -- | -- | +| Query | The thread is executing a statement | +| Sleep | Waiting for the client to send it an execution statement | +| Quit | The thread is exiting | +| Kill | Executing the kill statement | - ```SQL - SHOW PROCESSLIST - ``` - return - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` +## Usage Notes -## Keywords +In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. - SHOW, PROCESSLIST +## Examples + +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` -## Best Practice diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md index 105640ee921a4..aefd55c491d81 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md @@ -24,166 +24,186 @@ specific language governing permissions and limitations under the License. --> - ## Description -This statement is used to show the query hit statistics of the database and table +This statement is used to display the database table columns hit by the historical query -grammar: +## Syntax ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; ``` -Remarks: +## Optional Parameters + +**1. ``** + +> If this parameter is set, the matching information of the database is displayed + +**2. ``** + +> If this parameter is set, the matching status of a table is queried + +**3. `ALL`** + +> ALL Specifies whether to display the matching information of all indexes + +**4. `VERBOSE`** + +> VERBOSE displays detailed matching information + +## Usage Notes + +- Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. + +- You can use FOR DATABASE and FROM TABLE to specify the matching information of the database or table to be queried, followed by the database name or table name. + +- The ALL and VERBOSE parameters can be used alone or together, but they must be used last and only for table queries. + +- If no databases are being used, then simply executing 'SHOW QUERY STATS' will show the hits of all databases. + +- There may be two columns in the hit result: QueryCount indicates the number of times the column has been queried, and FilterCount indicates the number of times the column has been queried as the where condition. -1. Support query database and table history query hit statistics, restart fe after data will be reset, each fe separately statistics -2. Use FOR DATABASE and FROM TABLE to specify the query database or table hit statistics, respectively followed by the database name or table name -3. ALL can specify whether to display all index query hit statistics, VERBOSE can display more detailed hit statistics, these two parameters can be used separately, but must be placed at the end and can only be used on table queries -4. If no database is used, execute `SHOW QUERY STATS` directly to display the hit statistics of all databases -5. The result may have two columns: - QueryCount: The number of times the column was queried - FilterCount: The number of times the column was queried as a where condition ## Examples -1. Show the query hit statistics for `baseall` - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. Show the query hit statistics summary for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. Show the query hit statistics detail info for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. Show the query hit for a database - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. Show query hit statistics for all the databases - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## Keywords - - SHOW, QUERY, STATS; - -## Best Practice +```sql +show query stats from baseall +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` + +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index aa4d621d9b060..560f01ba609b9 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -24,46 +24,64 @@ specific language governing permissions and limitations under the License. --> - - ## Description This statement is used to clear query statistics -grammar: +## Syntax ```sql -CLEAN [ALL| DATABASE | TABLE] QUERY STATS [[FOR db_name]|[FROM|IN] table_name]]; +CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | IN } ] ]]; ``` -Remarks: +## Required Parameters + +**1. `ALL`** + +> ALL Clears all statistics + +**2. `DATABASE`** + +> DATABASE clears statistics of a database + +**3. `TABLE`** + +> TABLE Indicates that statistics of a table are cleared + +## Optional Parameters + +**1. ``** -1. If ALL is specified, all query statistics are cleared, including database and table, admin privilege is needed -2. If DATABASE is specified, the query statistics of the specified database are cleared, alter privilege for this database is needed -3. If TABLE is specified, the query statistics of the specified table are cleared, alter privilege for this table is needed +> If this parameter is set, the statistics of the corresponding database are cleared -## Example +**2. ``** -1. Clear all statistics -2. - ```sql - clean all query stats; - ``` +> If this parameter is set, the statistics of the corresponding table are cleared -2. Clear the specified database statistics - ```sql - clean database query stats for test_query_db; - ``` -3. Clear the specified table statistics +## Access Control Requirements - ```sql - clean table query stats from test_query_db.baseall; - ``` +The user who executes this SQL command must have at least the following permissions: -## Keywords +| Privilege | Object | Notes | +|:-------------|:---------|:--------------------------| +| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN | TABLE | If you specify a table, you need alter permission for that table | - CLEAN, QUERY, STATS -## Best Practice +## Examples + +```sql +clean all query stats +``` + +```sql +clean database query stats for test_query_db +``` + +```sql +clean table query stats from test_query_db.baseall +``` + diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md index 9d834229cfbff..f4cf5ae28cdbc 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -24,62 +24,74 @@ specific language governing permissions and limitations under the License. --> +## Description +Each Doris connection runs in a separate thread. Use this statement to terminate the thread. -In Doris, each connection runs in a separate thread. You can terminate a thread using the `KILL processlist_id`statement. +## Syntax -The `processlist_id` for the thread can be found in the Id column from the SHOW PROCESSLIST output. Or you can use the `SELECT CONNECTION_ID()` command to query the current connection id. +```SQL +KILL [CONNECTION] +``` -Syntax: +## Varaint Syntax -```sql -KILL [CONNECTION] processlist_id +```SQL +KILL QUERY [ { | } ] ``` -## Kill query +## Required Parameters -You can also terminate the query command under execution based on the processlist_id or the query_id. +**1. ``** -Syntax: +> Indicates the ID of the connection thread that needs to be killed -```sql -KILL QUERY processlist_id | query_id -``` +**2. ``** + +> Indicates the ID of the query to be killed + +## Optional Parameters + +**1. `CONNECTION`** + +> Indicates whether the thread is currently connected + +## Usage Notes -## Example +- The thread process list identifier can be queried from the Id column output by the SHOW PROCESSLIST -1. Check the current connection id. +- The Connection ID can be queried from SELECT CONNECTION_ID() + +## Examples ```sql -mysql select connection_id(); +select connection_id() +``` + +```text +-----------------+ | connection_id() | +-----------------+ | 48 | +-----------------+ -1 row in set (0.00 sec) ``` -2. Check all connection id. - ```sql -mysql SHOW PROCESSLIST; +SHOW PROCESSLIST +``` + +```text +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -| Yes | 48 | root | 10.16.xx.xx:44834 | 2023-12-29 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | -| | 50 | root | 192.168.xx.xx:52837 | 2023-12-29 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | -| | 51 | root | 192.168.xx.xx:52843 | 2023-12-29 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | -| | 55 | root | 192.168.xx.xx:55533 | 2023-12-29 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | -| | 47 | root | 10.16.xx.xx:35678 | 2023-12-29 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +| Yes | 48 | root | 10.16.xx.xx:44834 | 2025-01-21 16:49:47 | internal | test | Query | 0 | OK | e6e4ce9567b04859-8eeab8d6b5513e38 | SHOW PROCESSLIST | +| | 50 | root | 192.168.xx.xx:52837 | 2025-01-21 16:51:34 | internal | | Sleep | 1837 | EOF | deaf13c52b3b4a3b-b25e8254b50ff8cb | SELECT @@session.transaction_isolation | +| | 51 | root | 192.168.xx.xx:52843 | 2025-01-21 16:51:35 | internal | | Sleep | 907 | EOF | 437f219addc0404f-9befe7f6acf9a700 | /* ApplicationName=DBeaver Ultimate 23.1.3 - Metadata */ SHOW STATUS | +| | 55 | root | 192.168.xx.xx:55533 | 2025-01-21 17:09:32 | internal | test | Sleep | 271 | EOF | f02603dc163a4da3-beebbb5d1ced760c | /* ApplicationName=DBeaver Ultimate 23.1.3 - SQLEditor */ SELECT DATABASE() | +| | 47 | root | 10.16.xx.xx:35678 | 2025-01-21 16:21:56 | internal | test | Sleep | 3528 | EOF | f4944c543dc34a99-b0d0f3986c8f1c98 | select * from test | +------------------+------+------+--------------------+---------------------+----------+---------+---------+------+-------+-----------------------------------+---------------------------------------------------------------------------------------+ -5 rows in set (0.00 sec) ``` -3. Kill the currently running query, which will then be displayed as canceled. - ```sql -mysql kill query 55; -Query OK, 0 rows affected (0.01 sec) -``` - +kill 51 +``` \ No newline at end of file diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 35b1b93092413..0091f0641f89a 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -25,68 +25,65 @@ specific language governing permissions and limitations under the License. --> - - - ## Description -Display the running threads of the user. It should be noted that except the root user who can see all running threads, other users can only see their own running threads, and cannot see the running threads of other users. +Displays the thread that the user is running -Only display current connected FE's connection list by default, you can set session variable ```set show_all_fe_connection = true``` to show all FE's connection. - -grammar: +## Syntax ```sql SHOW [FULL] PROCESSLIST ``` -illustrate: - -- CurrentConnected: Indicates whether the connection is currently connected -- Id: It is the unique identifier of this thread. When we find that there is a problem with this thread, we can use the kill command to add this Id value to kill this thread. -- User: refers to the user who started this thread. -- Host: Records the IP and port number of the client sending the request. Through this information, when troubleshooting the problem, we can locate which client and which process sent the request. -- LoginTime: Timestamp when the connection is make. -- Catalog: Catalog name. -- Db: which database the currently executed command is on. If no database is specified, the value is NULL . -- Command: refers to the command that the thread is executing at the moment. -- Time: Indicates the time the thread is in the current state. -- State: The state of the thread, corresponding to Command. -- QueryId: The ID of the current query statement. -- Info: Generally recorded is the statement executed by the thread. By default, only the first 100 characters are displayed, that is, the statement you see may be truncated. To see all the information, you need to use show full processlist. +## Optional Parameters -Common Command types are as follows: +**1. `FULL`** -- Query: The thread is executing a statement -- Sleep: is waiting for a client to send it an execute statement -- Quit: the thread is exiting -- Kill : The kill statement is being executed to kill the specified thread +> 表示是否查看其他用户的连接信息 -Other types can refer to [MySQL official website for explanation](https://dev.mysql.com/doc/refman/5.6/en/thread-commands.html) +## Return Value -## Example +| column | Instructions | +|------------------|--------------------------------------| +| CurrentConnected | Whether the connection is current | +| Id | The unique identification of this thread | +| User | The user who started this thread | +| Host | The IP address and port number of the client sending the request are recorded | +| LoginTime | Time to establish a connection | +| Catalog | In which data directory is the command currently executed | +| Db | On which database is the command being executed? If no database is specified, the value is NULL | +| Command | The command that the thread is executing at this moment | +| Time | Time when the previous command is submitted to the current status, in seconds | +| State | State of thread | +| QueryId | ID of the current query statement | +| Info | Generally, the statement executed by the thread is recorded, and only the first 100 characters are displayed by default | -1. View the threads running by the current user +Common Command types are as follows: - ```SQL - SHOW PROCESSLIST - ``` +| column | Instructions | +| -- | -- | +| Query | The thread is executing a statement | +| Sleep | Waiting for the client to send it an execution statement | +| Quit | The thread is exiting | +| Kill | Executing the kill statement | - return +## Usage Notes - ``` - MySQL [test]> show full processlist; - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - | Yes | 0 | root | 127.0.0.1:34650 | 2023-09-06 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | - | | 1 | root | 127.0.0.1:34776 | 2023-09-06 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | - +------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ - ``` +In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. -## Keywords +## Examples - SHOW, PROCESSLIST +```sql +SHOW PROCESSLIST +``` + +```text ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| CurrentConnected | Id | User | Host | LoginTime | Catalog | Db | Command | Time | State | QueryId | Info | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +| Yes | 0 | root | 127.0.0.1:34650 | 2025-01-21 12:01:02 | internal | test | Query | 0 | OK | c84e397193a54fe7-bbe9bc219318b75e | select 1 | +| | 1 | root | 127.0.0.1:34776 | 2025-01-21 12:01:07 | internal | | Sleep | 29 | EOF | 886ffe2894314f50-8dd73a6ca06699e4 | show full processlist | ++------------------+------+------+-----------------+---------------------+----------+------+---------+------+-------+-----------------------------------+-----------------------+ +``` -## Best Practice diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 30939a5a45625..aefd55c491d81 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -26,163 +26,184 @@ under the License. ## Description -This statement is used to show the query hit statistics of the database and table +This statement is used to display the database table columns hit by the historical query -grammar: +## Syntax ```sql -SHOW QUERY STATS [[FOR db_name]|[FROM table_name]] [ALL] [VERBOSE]]; +SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; ``` -Remarks: - -1. Support query database and table history query hit statistics, restart fe after data will be reset, each fe separately statistics -2. Use FOR DATABASE and FROM TABLE to specify the query database or table hit statistics, respectively followed by the database name or table name -3. ALL can specify whether to display all index query hit statistics, VERBOSE can display more detailed hit statistics, these two parameters can be used separately, but must be placed at the end and can only be used on table queries -4. If no database is used, execute `SHOW QUERY STATS` directly to display the hit statistics of all databases -5. The result may have two columns: - QueryCount: The number of times the column was queried - FilterCount: The number of times the column was queried as a where condition -## Example - -1. Show the query hit statistics for `baseall` - - ```sql - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 0 | 0 | - | k1 | 0 | 0 | - | k2 | 0 | 0 | - | k3 | 0 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 0 | 0 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.002 sec) - - MySQL [test_query_db]> select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2; - +------+------+--------+-------------+ - | k0 | k1 | k2 | sum(`k3`) | - +------+------+--------+-------------+ - | 0 | 6 | 32767 | 3021 | - | 1 | 12 | 32767 | -2147483647 | - | 0 | 3 | 1989 | 1002 | - | 0 | 7 | -32767 | 1002 | - | 1 | 8 | 255 | 2147483647 | - | 1 | 9 | 1991 | -2147483647 | - | 1 | 11 | 1989 | 25699 | - | 1 | 13 | -32767 | 2147483647 | - | 1 | 14 | 255 | 103 | - | 0 | 1 | 1989 | 1001 | - | 0 | 2 | 1986 | 1001 | - | 1 | 15 | 1992 | 3021 | - +------+------+--------+-------------+ - 12 rows in set (0.050 sec) - - MySQL [test_query_db]> show query stats from baseall; - +-------+------------+-------------+ - | Field | QueryCount | FilterCount | - +-------+------------+-------------+ - | k0 | 1 | 0 | - | k1 | 1 | 0 | - | k2 | 1 | 0 | - | k3 | 1 | 0 | - | k4 | 0 | 0 | - | k5 | 0 | 0 | - | k6 | 0 | 0 | - | k10 | 0 | 0 | - | k11 | 0 | 0 | - | k7 | 0 | 0 | - | k8 | 0 | 0 | - | k9 | 1 | 1 | - | k12 | 0 | 0 | - | k13 | 0 | 0 | - +-------+------------+-------------+ - 14 rows in set (0.001 sec) - ``` - -2. Show the query hit statistics summary for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all; - +-----------+------------+ - | IndexName | QueryCount | - +-----------+------------+ - | baseall | 1 | - +-----------+------------+ - 1 row in set (0.005 sec) - ``` - -3. Show the query hit statistics detail info for all the mv in a table - - ```sql - MySQL [test_query_db]> show query stats from baseall all verbose; - +-----------+-------+------------+-------------+ - | IndexName | Field | QueryCount | FilterCount | - +-----------+-------+------------+-------------+ - | baseall | k0 | 1 | 0 | - | | k1 | 1 | 0 | - | | k2 | 1 | 0 | - | | k3 | 1 | 0 | - | | k4 | 0 | 0 | - | | k5 | 0 | 0 | - | | k6 | 0 | 0 | - | | k10 | 0 | 0 | - | | k11 | 0 | 0 | - | | k7 | 0 | 0 | - | | k8 | 0 | 0 | - | | k9 | 1 | 1 | - | | k12 | 0 | 0 | - | | k13 | 0 | 0 | - +-----------+-------+------------+-------------+ - 14 rows in set (0.017 sec) - ``` - -4. Show the query hit for a database - - ```sql - MySQL [test_query_db]> show query stats for test_query_db; - +----------------------------+------------+ - | TableName | QueryCount | - +----------------------------+------------+ - | compaction_tbl | 0 | - | bigtable | 0 | - | empty | 0 | - | tempbaseall | 0 | - | test | 0 | - | test_data_type | 0 | - | test_string_function_field | 0 | - | baseall | 1 | - | nullable | 0 | - +----------------------------+------------+ - 9 rows in set (0.005 sec) - ``` - -5. Show query hit statistics for all the databases - - ```sql - MySQL [(none)]> show query stats; - +-----------------+------------+ - | Database | QueryCount | - +-----------------+------------+ - | test_query_db | 1 | - +-----------------+------------+ - 1 rows in set (0.005 sec) - ``` - SHOW QUERY STATS; - ``` - -## Keywords - - SHOW, QUERY, STATS; - -## Best Practice +## Optional Parameters + +**1. ``** + +> If this parameter is set, the matching information of the database is displayed + +**2. ``** + +> If this parameter is set, the matching status of a table is queried + +**3. `ALL`** + +> ALL Specifies whether to display the matching information of all indexes + +**4. `VERBOSE`** + +> VERBOSE displays detailed matching information + +## Usage Notes + +- Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. + +- You can use FOR DATABASE and FROM TABLE to specify the matching information of the database or table to be queried, followed by the database name or table name. + +- The ALL and VERBOSE parameters can be used alone or together, but they must be used last and only for table queries. + +- If no databases are being used, then simply executing 'SHOW QUERY STATS' will show the hits of all databases. + +- There may be two columns in the hit result: QueryCount indicates the number of times the column has been queried, and FilterCount indicates the number of times the column has been queried as the where condition. + +## Examples + +```sql +show query stats from baseall +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 0 | 0 | + | k1 | 0 | 0 | + | k2 | 0 | 0 | + | k3 | 0 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 0 | 0 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +select k0, k1,k2, sum(k3) from baseall where k9 > 1 group by k0,k1,k2 +``` + +```text + +------+------+--------+-------------+ + | k0 | k1 | k2 | sum(`k3`) | + +------+------+--------+-------------+ + | 0 | 6 | 32767 | 3021 | + | 1 | 12 | 32767 | -2147483647 | + | 0 | 3 | 1989 | 1002 | + | 0 | 7 | -32767 | 1002 | + | 1 | 8 | 255 | 2147483647 | + | 1 | 9 | 1991 | -2147483647 | + | 1 | 11 | 1989 | 25699 | + | 1 | 13 | -32767 | 2147483647 | + | 1 | 14 | 255 | 103 | + | 0 | 1 | 1989 | 1001 | + | 0 | 2 | 1986 | 1001 | + | 1 | 15 | 1992 | 3021 | + +------+------+--------+-------------+ +``` + + ```sql +show query stats from baseall; +``` + +```text + +-------+------------+-------------+ + | Field | QueryCount | FilterCount | + +-------+------------+-------------+ + | k0 | 1 | 0 | + | k1 | 1 | 0 | + | k2 | 1 | 0 | + | k3 | 1 | 0 | + | k4 | 0 | 0 | + | k5 | 0 | 0 | + | k6 | 0 | 0 | + | k10 | 0 | 0 | + | k11 | 0 | 0 | + | k7 | 0 | 0 | + | k8 | 0 | 0 | + | k9 | 1 | 1 | + | k12 | 0 | 0 | + | k13 | 0 | 0 | + +-------+------------+-------------+ +``` + +```sql +show query stats from baseall all +``` + +```text + +-----------+------------+ + | IndexName | QueryCount | + +-----------+------------+ + | baseall | 1 | + +-----------+------------+ +``` + +```sql +show query stats from baseall all verbose +``` + +```text + +-----------+-------+------------+-------------+ + | IndexName | Field | QueryCount | FilterCount | + +-----------+-------+------------+-------------+ + | baseall | k0 | 1 | 0 | + | | k1 | 1 | 0 | + | | k2 | 1 | 0 | + | | k3 | 1 | 0 | + | | k4 | 0 | 0 | + | | k5 | 0 | 0 | + | | k6 | 0 | 0 | + | | k10 | 0 | 0 | + | | k11 | 0 | 0 | + | | k7 | 0 | 0 | + | | k8 | 0 | 0 | + | | k9 | 1 | 1 | + | | k12 | 0 | 0 | + | | k13 | 0 | 0 | + +-----------+-------+------------+-------------+ +``` + +```sql +show query stats for test_query_db +``` + +```text + +----------------------------+------------+ + | TableName | QueryCount | + +----------------------------+------------+ + | compaction_tbl | 0 | + | bigtable | 0 | + | empty | 0 | + | tempbaseall | 0 | + | test | 0 | + | test_data_type | 0 | + | test_string_function_field | 0 | + | baseall | 1 | + | nullable | 0 | + +----------------------------+------------+ +``` + +```sql +show query stats +``` + +```text + +-----------------+------------+ + | Database | QueryCount | + +-----------------+------------+ + | test_query_db | 1 | + +-----------------+------------+ +``` From 1a396ab5f51007551457a522b37e8060c9b8f2da Mon Sep 17 00:00:00 2001 From: wyx123654 <961871881@qq.com> Date: Wed, 22 Jan 2025 18:06:52 +0800 Subject: [PATCH 2/5] add Access Control --- .../sql-statements/session/queries/SHOW-QUERY-STATS.md | 8 ++++++++ .../sql-statements/session/queries/SHOW-QUERY-STATS.md | 8 ++++++++ .../sql-statements/session/query/SHOW-QUERY-STATS.md | 8 ++++++++ .../sql-statements/session/queries/SHOW-QUERY-STATS.md | 8 ++++++++ .../sql-statements/session/query/SHOW-QUERY-STATS.md | 8 ++++++++ .../sql-statements/session/queries/SHOW-QUERY-STATS.md | 8 ++++++++ 6 files changed, 48 insertions(+) diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index aefd55c491d81..d15c0d5464b99 100644 --- a/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE displays detailed matching information +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------------|:----------|:-------------------| +| SELECT_PRIV | DATABASE | You must have the SELECT permission on the queried database | + ## Usage Notes - Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 62342f8efd97d..d80a0e71f28a2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE 可以展示更详细的命中情况 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-------------------| +| SELECT_PRIV | DATABASE | 需要对查询的数据库有 SELECT 权限 | + ## 注意事项 - 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md index 62342f8efd97d..d80a0e71f28a2 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE 可以展示更详细的命中情况 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-------------------| +| SELECT_PRIV | DATABASE | 需要对查询的数据库有 SELECT 权限 | + ## 注意事项 - 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index 0334815f1f13a..b48bc5586cb0f 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE 可以展示更详细的命中情况 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-------------------| +| SELECT_PRIV | DATABASE | 需要对查询的数据库有 SELECT 权限 | + ## 注意事项 - 支持查询数据库和表的历史查询命中情况,重启 fe 后数据会重置,每个 fe 单独统计。 diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md index aefd55c491d81..d15c0d5464b99 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE displays detailed matching information +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------------|:----------|:-------------------| +| SELECT_PRIV | DATABASE | You must have the SELECT permission on the queried database | + ## Usage Notes - Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md index aefd55c491d81..d15c0d5464b99 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-QUERY-STATS.md @@ -52,6 +52,14 @@ SHOW QUERY STATS [ { [FOR ] | [FROM ] } ] [ALL] [VERBOSE]]; > VERBOSE displays detailed matching information +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------------|:----------|:-------------------| +| SELECT_PRIV | DATABASE | You must have the SELECT permission on the queried database | + ## Usage Notes - Query the historical query matching status of databases and tables. Data is reset after fe is restarted, and statistics are collected for each fe. From 89e0a5df581433b91e857030378d84b9d77e67c3 Mon Sep 17 00:00:00 2001 From: wyx123654 <961871881@qq.com> Date: Wed, 22 Jan 2025 18:36:19 +0800 Subject: [PATCH 3/5] fix doc --- .../sql-statements/session/queries/SHOW-PROCESSLIST.md | 8 ++++++-- .../sql-statements/session/queries/SHOW-PROCESSLIST.md | 7 +++++-- .../sql-statements/session/query/SHOW-PROCESSLIST.md | 8 ++++++-- .../sql-statements/session/queries/SHOW-PROCESSLIST.md | 8 ++++++-- .../sql-statements/session/query/SHOW-PROCESSLIST.md | 9 +++++++-- .../sql-statements/session/queries/SHOW-PROCESSLIST.md | 9 +++++++-- 6 files changed, 37 insertions(+), 12 deletions(-) diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 0091f0641f89a..b811e0c1279b5 100644 --- a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -67,9 +67,13 @@ Common Command types are as follows: | Quit | The thread is exiting | | Kill | Executing the kill statement | -## Usage Notes +## Access Control Requirements -In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------|:----------|:---------------------------| +| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | ## Examples diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 5ed3db5e86856..75d225cfb9c1d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -66,10 +66,13 @@ SHOW [FULL] PROCESSLIST | Quit | 该线程正在退出 | | Kill | 正在执行 kill 语句 | -## 注意事项 +## 权限控制 -除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +执行此 SQL 命令的用户必须至少具有以下权限: +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:---------------------------| +| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | ## 示例 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index 5ed3db5e86856..e6771456d490d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -66,9 +66,13 @@ SHOW [FULL] PROCESSLIST | Quit | 该线程正在退出 | | Kill | 正在执行 kill 语句 | -## 注意事项 +## 权限控制 -除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:---------------------------| +| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 5ed3db5e86856..e6771456d490d 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -66,9 +66,13 @@ SHOW [FULL] PROCESSLIST | Quit | 该线程正在退出 | | Kill | 正在执行 kill 语句 | -## 注意事项 +## 权限控制 -除了 root 用户能看到所有正在运行的线程外,其他用户都只能看到自己正在运行的线程,看不到其它用户正在运行的线程 +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:---------------------------| +| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | ## 示例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index 8f65751a17dd5..e96afa30092e1 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -66,9 +66,14 @@ Common Command types are as follows: | Quit | The thread is exiting | | Kill | Executing the kill statement | -## Usage Notes +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------|:----------|:---------------------------| +| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | -In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. ## Examples diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 0091f0641f89a..ae43069a10e57 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -67,9 +67,14 @@ Common Command types are as follows: | Quit | The thread is exiting | | Kill | Executing the kill statement | -## Usage Notes +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:-------------|:----------|:---------------------------| +| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | -In addition to the root user can see all running threads, other users can only see their own running threads and cannot see other users' running threads. ## Examples From 4bd731a7485c344bd57fa7290c592cbe24afd2e3 Mon Sep 17 00:00:00 2001 From: wyx123654 <961871881@qq.com> Date: Wed, 22 Jan 2025 21:09:43 +0800 Subject: [PATCH 4/5] fix ALL description --- .../sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md | 2 +- .../sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md | 2 +- .../sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index 560f01ba609b9..e66157ea416a0 100644 --- a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -38,7 +38,7 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **1. `ALL`** -> ALL Clears all statistics +> Use ALL to clear all query statistics **2. `DATABASE`** diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md index 560f01ba609b9..e66157ea416a0 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md @@ -38,7 +38,7 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **1. `ALL`** -> ALL Clears all statistics +> Use ALL to clear all query statistics **2. `DATABASE`** diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index 560f01ba609b9..e66157ea416a0 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -38,7 +38,7 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **1. `ALL`** -> ALL Clears all statistics +> Use ALL to clear all query statistics **2. `DATABASE`** From 5e700e3c1be24a60641f02d1f3375780a6c1e671 Mon Sep 17 00:00:00 2001 From: wyx123654 <961871881@qq.com> Date: Thu, 23 Jan 2025 11:18:33 +0800 Subject: [PATCH 5/5] fix quanxian --- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 14 +++++++------- .../sql-statements/session/queries/KILL-QUERY.md | 8 ++++++++ .../session/queries/SHOW-PROCESSLIST.md | 4 ++-- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 6 +++--- .../sql-statements/session/queries/KILL-QUERY.md | 8 ++++++++ .../session/queries/SHOW-PROCESSLIST.md | 3 ++- .../session/query/CLEAN-ALL-QUERY-STATS.md | 6 +++--- .../sql-statements/session/query/KILL-QUERY.md | 8 ++++++++ .../session/query/SHOW-PROCESSLIST.md | 2 +- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 6 +++--- .../sql-statements/session/queries/KILL-QUERY.md | 8 ++++++++ .../session/queries/SHOW-PROCESSLIST.md | 2 +- .../session/query/CLEAN-ALL-QUERY-STATS.md | 10 +++++----- .../sql-statements/session/query/KILL-QUERY.md | 8 ++++++++ .../session/query/SHOW-PROCESSLIST.md | 4 ++-- .../session/queries/CLEAN-ALL-QUERY-STATS.md | 10 +++++----- .../sql-statements/session/queries/KILL-QUERY.md | 8 ++++++++ .../session/queries/SHOW-PROCESSLIST.md | 4 ++-- 18 files changed, 84 insertions(+), 35 deletions(-) diff --git a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index e66157ea416a0..095648f906ad9 100644 --- a/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/docs/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -42,11 +42,11 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **2. `DATABASE`** -> DATABASE clears statistics of a database +> Use DATABASE to clear database query statistics **3. `TABLE`** -> TABLE Indicates that statistics of a table are cleared +> Use TABLE to clear table query statistics ## Optional Parameters @@ -63,11 +63,11 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM The user who executes this SQL command must have at least the following permissions: -| Privilege | Object | Notes | -|:-------------|:---------|:--------------------------| -| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | -| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | -| ADMIN | TABLE | If you specify a table, you need alter permission for that table | +| Privilege | Object | Notes | +|:-----------|:---------|:--------------------------| +| ADMIN_PRIV | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER_PRIV | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN_PRIV | TABLE | If you specify a table, you need alter permission for that table | ## Examples diff --git a/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md index ad04531f15287..87cc391fc5d2a 100644 --- a/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/docs/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -56,6 +56,14 @@ KILL QUERY [ { | } ] > Indicates whether the thread is currently connected +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | DATABASE | GRANT permission is required for the KILL statement | + ## Usage Notes - The thread process list identifier can be queried from the Id column output by the SHOW PROCESSLIST diff --git a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index b811e0c1279b5..5805415aa42b9 100644 --- a/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/docs/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -39,7 +39,7 @@ SHOW [FULL] PROCESSLIST **1. `FULL`** -> 表示是否查看其他用户的连接信息 +> Indicates whether to view the connection information of other users ## Return Value @@ -73,7 +73,7 @@ The user who executes this SQL command must have at least the following permissi | Privilege | Object | Notes | |:-------------|:----------|:---------------------------| -| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | +| ADMIN_PRIV | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | ## Examples diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index af3ef5923668b..2e7ed41c10952 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -65,9 +65,9 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:--------------------------| -| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | -| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | -| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | +| ADMIN_PRIV | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER_PRIV | 数据库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN_PRIV | 表 | 如果指定表则需要对应表的 alter 权限 | ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md index 17dd8b749c567..4fc97352d7472 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -56,6 +56,14 @@ KILL QUERY [ { | } ] > 表示是否是当前连接的线程 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | 数据库 | 若需要 KILL 语句需要获得 GRANT 权限 | + ## 注意事项 - 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index 75d225cfb9c1d..b43d5eba40abb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/current/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -72,7 +72,8 @@ SHOW [FULL] PROCESSLIST | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:---------------------------| -| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | +| ADMIN_PRIV | 数据库 | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | + ## 示例 ```sql diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md index 541609a9b0f70..561c53e603129 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md @@ -65,9 +65,9 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:--------------------------| -| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | -| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | -| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | +| ADMIN_PRIV | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER_PRIV | 数据库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN_PRIV | 表 | 如果指定表则需要对应表的 alter 权限 | ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md index 17dd8b749c567..4fc97352d7472 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md @@ -56,6 +56,14 @@ KILL QUERY [ { | } ] > 表示是否是当前连接的线程 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | 数据库 | 若需要 KILL 语句需要获得 GRANT 权限 | + ## 注意事项 - 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index e6771456d490d..b43d5eba40abb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -72,7 +72,7 @@ SHOW [FULL] PROCESSLIST | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:---------------------------| -| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | +| ADMIN_PRIV | 数据库 | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index af3ef5923668b..ed749c27b7860 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -65,9 +65,9 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:--------------------------| -| ADMIN | ALL | 如果指定 ALL 则需要 ADMIN 权限 | -| ALTER | 库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | -| ADMIN | 表 | 如果指定表则需要对应表的 alter 权限 | +| ADMIN_PRIV | ALL | 如果指定 ALL 则需要 ADMIN 权限 | +| ALTER_PRIV | 数据库 | 如果指定数据库则需要对应数据库的 ALTER 权限 | +| ADMIN_PRIV | 表 | 如果指定表则需要对应表的 alter 权限 | ## 示例 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md index 17dd8b749c567..4c02e98c8ca16 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -56,6 +56,14 @@ KILL QUERY [ { | } ] > 表示是否是当前连接的线程 +## 权限控制 + +执行此 SQL 命令的用户必须至少具有以下权限: + +| 权限(Privilege) | 对象(Object) | 说明(Notes) | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | 数据库 | 若需要 KILL 语句需要获得 GRANT 权限 | + ## 注意事项 - 线程进程列表标识符可以从 SHOW PROCESSLIST 输出的 Id 列查询 diff --git a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index e6771456d490d..b43d5eba40abb 100644 --- a/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/i18n/zh-CN/docusaurus-plugin-content-docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -72,7 +72,7 @@ SHOW [FULL] PROCESSLIST | 权限(Privilege) | 对象(Object) | 说明(Notes) | |:--------------|:-----------|:---------------------------| -| ADMIN | DATABASE | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | +| ADMIN_PRIV | 数据库 | 若需要查看其他用户的连接信息则需要 ADMIN 权限 | ## 示例 diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md index e66157ea416a0..4293a2597d378 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/CLEAN-ALL-QUERY-STATS.md @@ -42,11 +42,11 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **2. `DATABASE`** -> DATABASE clears statistics of a database +> Use DATABASE to clear database query statistics **3. `TABLE`** -> TABLE Indicates that statistics of a table are cleared +> Use TABLE to clear table query statistics ## Optional Parameters @@ -65,9 +65,9 @@ The user who executes this SQL command must have at least the following permissi | Privilege | Object | Notes | |:-------------|:---------|:--------------------------| -| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | -| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | -| ADMIN | TABLE | If you specify a table, you need alter permission for that table | +| ADMIN_PRIV | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER_PRIV | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN_PRIV | TABLE | If you specify a table, you need alter permission for that table | ## Examples diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md index ad04531f15287..87cc391fc5d2a 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/KILL-QUERY.md @@ -56,6 +56,14 @@ KILL QUERY [ { | } ] > Indicates whether the thread is currently connected +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | DATABASE | GRANT permission is required for the KILL statement | + ## Usage Notes - The thread process list identifier can be queried from the Id column output by the SHOW PROCESSLIST diff --git a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md index e96afa30092e1..f1a3eec9f2c2c 100644 --- a/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-2.1/sql-manual/sql-statements/session/query/SHOW-PROCESSLIST.md @@ -38,7 +38,7 @@ SHOW [FULL] PROCESSLIST **1. `FULL`** -> 表示是否查看其他用户的连接信息 +> Indicates whether to view the connection information of other users ## Return Value @@ -72,7 +72,7 @@ The user who executes this SQL command must have at least the following permissi | Privilege | Object | Notes | |:-------------|:----------|:---------------------------| -| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | +| ADMIN_PRIV | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | ## Examples diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md index e66157ea416a0..4293a2597d378 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/CLEAN-ALL-QUERY-STATS.md @@ -42,11 +42,11 @@ CLEAN [ { ALL| DATABASE | TABLE } ] QUERY STATS [ { [ FOR ] | [ { FROM **2. `DATABASE`** -> DATABASE clears statistics of a database +> Use DATABASE to clear database query statistics **3. `TABLE`** -> TABLE Indicates that statistics of a table are cleared +> Use TABLE to clear table query statistics ## Optional Parameters @@ -65,9 +65,9 @@ The user who executes this SQL command must have at least the following permissi | Privilege | Object | Notes | |:-------------|:---------|:--------------------------| -| ADMIN | ALL | If ALL is specified, the ADMIN permission is required | -| ALTER | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | -| ADMIN | TABLE | If you specify a table, you need alter permission for that table | +| ADMIN_PRIV | ALL | If ALL is specified, the ADMIN permission is required | +| ALTER_PRIV | DATABASE | If the database is specified, the ALTER permission for the corresponding database is required | +| ADMIN_PRIV | TABLE | If you specify a table, you need alter permission for that table | ## Examples diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md index f4cf5ae28cdbc..f30b4f4a65818 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/KILL-QUERY.md @@ -62,6 +62,14 @@ KILL QUERY [ { | } ] - The Connection ID can be queried from SELECT CONNECTION_ID() +## Access Control Requirements + +The user who executes this SQL command must have at least the following permissions: + +| Privilege | Object | Notes | +|:--------------|:-----------|:-----------------------| +| GRANT_PRIV | DATABASE | GRANT permission is required for the KILL statement | + ## Examples ```sql diff --git a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md index ae43069a10e57..a2d868bdbf5f9 100644 --- a/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md +++ b/versioned_docs/version-3.0/sql-manual/sql-statements/session/queries/SHOW-PROCESSLIST.md @@ -39,7 +39,7 @@ SHOW [FULL] PROCESSLIST **1. `FULL`** -> 表示是否查看其他用户的连接信息 +> Indicates whether to view the connection information of other users ## Return Value @@ -73,7 +73,7 @@ The user who executes this SQL command must have at least the following permissi | Privilege | Object | Notes | |:-------------|:----------|:---------------------------| -| ADMIN | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | +| ADMIN_PRIV | DATABASE | If you want to view the connection information of other users, you need the ADMIN permission | ## Examples