Skip to content

Commit

Permalink
sql: update slow query document (#663)
Browse files Browse the repository at this point in the history
* sql: update slow query document

* address comment

* address comment

* address comment
  • Loading branch information
tiancaiamao authored and lilin90 committed Oct 12, 2018
1 parent 6397881 commit 1a1b2e5
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions sql/slow-query.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,3 +95,31 @@ 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

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
```

`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.

```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`.

0 comments on commit 1a1b2e5

Please sign in to comment.