From 5dc7777de7d5dbacaf6a65d4a4cca34af533cc23 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 11 Oct 2018 19:50:12 +0800 Subject: [PATCH 1/4] sql: update slow query document --- sql/slow-query.md | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/sql/slow-query.md b/sql/slow-query.md index 2f2e9a5e482be..c3f0a2d87e9f5 100644 --- a/sql/slow-query.md +++ b/sql/slow-query.md @@ -95,3 +95,25 @@ The SQL statement. Not all of the `SLOW_QUERY` statements are problematic. Only those whose `process_time` is very large will increase the pressure on the entire cluster. The statements whose `wait_time` is very large and `process_time` is very small are usually not problematic. The large `wait_time` is because the statement is blocked by real problematic statements and it has to wait in the execution queue, which leads to a much longer response time. + +### `admin show slow` command + +Besides obtaining the TiDB log file, another way to identify the slow query is through the `admin show slow` SQL command: + + admin show slow recent N + admin show slow top [internal | all] N + +`recent N` shows the recent N slow query records, for example: + + admin show recent 10 + +`top N` shows the slowest N query records recently (within a few days). +If the `internal` option is provided, the returned results would be the inner SQL executed by the system; +If the `all` option is provided, the returned results would be the user's SQL combinated with inner SQL; +Otherwise, this command would only return the slow query records from the user's SQL. + + admin show top 3 + admin show top internal 3 + admin show top all 5 + +Due to the memory footprint restriction, the stored slow query records count is limited. If the specified `N` is greater than the records count, the returned records count may be smaller than `N`. From 3ac7f9d6747382dff54b17c42d1f659884bfb500 Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Thu, 11 Oct 2018 22:25:55 +0800 Subject: [PATCH 2/4] address comment --- sql/slow-query.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/slow-query.md b/sql/slow-query.md index c3f0a2d87e9f5..a7bd4b6e48244 100644 --- a/sql/slow-query.md +++ b/sql/slow-query.md @@ -98,7 +98,7 @@ The statements whose `wait_time` is very large and `process_time` is very small ### `admin show slow` command -Besides obtaining the TiDB log file, another way to identify the slow query is through the `admin show slow` SQL command: +In addition to the TIDB log file, you can identify slow queries by running the `admin show slow` command: admin show slow recent N admin show slow top [internal | all] N From a9e41ef69fb040bc8c37d0ab3f3e9818795494ca Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Fri, 12 Oct 2018 12:56:03 +0800 Subject: [PATCH 3/4] address comment --- sql/slow-query.md | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/sql/slow-query.md b/sql/slow-query.md index a7bd4b6e48244..8546d9d55d642 100644 --- a/sql/slow-query.md +++ b/sql/slow-query.md @@ -98,22 +98,28 @@ The statements whose `wait_time` is very large and `process_time` is very small ### `admin show slow` command -In addition to the TIDB log file, you can identify slow queries by running the `admin show slow` command: +In addition to the TiDB log file, you can identify slow queries by running the `admin show slow` command: - admin show slow recent N - admin show slow top [internal | all] N +``` +admin show slow recent N +admin show slow top [internal | all] N +``` `recent N` shows the recent N slow query records, for example: - admin show recent 10 +``` +admin show recent 10 +``` `top N` shows the slowest N query records recently (within a few days). If the `internal` option is provided, the returned results would be the inner SQL executed by the system; If the `all` option is provided, the returned results would be the user's SQL combinated with inner SQL; Otherwise, this command would only return the slow query records from the user's SQL. - admin show top 3 - admin show top internal 3 - admin show top all 5 +``` +admin show top 3 +admin show top internal 3 +admin show top all 5 +``` Due to the memory footprint restriction, the stored slow query records count is limited. If the specified `N` is greater than the records count, the returned records count may be smaller than `N`. From 7113099b8c1053e5fda3d3a90a4adee7ec83a1fd Mon Sep 17 00:00:00 2001 From: tiancaiamao Date: Fri, 12 Oct 2018 13:20:49 +0800 Subject: [PATCH 4/4] address comment --- sql/slow-query.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sql/slow-query.md b/sql/slow-query.md index 8546d9d55d642..e919aadc01f26 100644 --- a/sql/slow-query.md +++ b/sql/slow-query.md @@ -100,14 +100,14 @@ The statements whose `wait_time` is very large and `process_time` is very small In addition to the TiDB log file, you can identify slow queries by running the `admin show slow` command: -``` +```sql admin show slow recent N admin show slow top [internal | all] N ``` `recent N` shows the recent N slow query records, for example: -``` +```sql admin show recent 10 ``` @@ -116,7 +116,7 @@ If the `internal` option is provided, the returned results would be the inner SQ If the `all` option is provided, the returned results would be the user's SQL combinated with inner SQL; Otherwise, this command would only return the slow query records from the user's SQL. -``` +```sql admin show top 3 admin show top internal 3 admin show top all 5