diff --git a/FAQ.md b/FAQ.md index 2e5b069f999f5..1639390e2f9c8 100644 --- a/FAQ.md +++ b/FAQ.md @@ -531,7 +531,7 @@ When TiDB is executing a SQL statement, the query will be `EXPENSIVE_QUERY` if e #### How to control or change the execution priority of SQL commits? -TiDB has the following high priority and low priority syntax: +TiDB supports changing the priority on a [per-session](sql/tidb-specific.md#tidb_force_priority), [global](sql/server-command-option.md#force-priority) or [individual statement basis](sql/dml.md). Priority has the following meaning: - HIGH_PRIORITY: this statement has a high priority, that is, TiDB gives priority to this statement and executes it first. diff --git a/sql/server-command-option.md b/sql/server-command-option.md index ed72ef6022202..851da50497797 100644 --- a/sql/server-command-option.md +++ b/sql/server-command-option.md @@ -157,6 +157,14 @@ Same as the "run-ddl" startup option - Default: true - When you execute `join` on tables without any conditions on both sides, the statement can be run by default. But if you set the value to `false`, the server does not run such `join` statement. +### force-priority + +- The default priority for statements +- Default: `NO_PRIORITY` +- TiDB supports the priorities `NO_PRIORITY` | `LOW_PRIORITY` | `DELAYED` | `HIGH_PRIORITY` for statements. One use case for changing the priority, is you may choose to dedicate a pool of servers for OLAP queries and set the value to `LOW_PRIORITY` to ensure that TiKV servers will provide priority to OLTP workloads which are routed to a different pool of TiDB servers. This helps ensure more uniform OLTP performance at the risk of slightly slower OLAP performance. + +TiDB will automatically set table scans to `LOW_PRIORITY` and overwriting priority on a per-statement basis is possible by using the `HIGH PRIORITY` or `LOW PRIORITY` [DML modifier](dml.md). + ### join-concurrency - The goroutine number when the `join-concurrency` runs `join` diff --git a/sql/tidb-specific.md b/sql/tidb-specific.md index 3e5d8a718d9fc..bf79439f6fc69 100644 --- a/sql/tidb-specific.md +++ b/sql/tidb-specific.md @@ -282,6 +282,13 @@ set @@global.tidb_distsql_scan_concurrency = 10 - This variable is used to set the priority of executing the `ADD INDEX` operation in the `re-organize` phase. - You can set the value of this variable to `PRIORITY_LOW`, `PRIORITY_NORMAL` or `PRIORITY_HIGH`. +### tidb_force_priority + +- Scope: SESSION +- Default value: `NO_PRIORITY` +- This variable is used to change the default priority for statements executed on a TiDB server. A use case is to ensure that a particular user that is performing OLAP queries receives lower priority than users performing OLTP queries. +- You can set the value of this variable to `NO_PRIORITY`, `LOW_PRIORITY`, `DELAYED` or `HIGH_PRIORITY`. + ## Optimizer Hint On the basis of MySQL’s `Optimizer Hint` Syntax, TiDB adds some proprietary `Hint` syntaxes. When using the `Hint` syntax, the TiDB optimizer will try to use the specific algorithm, which performs better than the default algorithm in some scenarios.