Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

faq, sql: Document tidb_force_priority #645

Merged
merged 7 commits into from
Oct 12, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please delete the extra space before "Priority".


- HIGH_PRIORITY: this statement has a high priority, that is, TiDB gives priority to this statement and executes it first.

Expand Down
8 changes: 8 additions & 0 deletions sql/server-command-option.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 `LOW_PRIORITY`, `NO_PRIORITY`, `HIGH_PRIORITY` and `DELAYED` for statements. One use case for changing the priority, is you may choose to dedicated 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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TiDB supports the priorities LOW_PRIORITY, NO_PRIORITY, HIGH_PRIORITY and DELAYED 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.

(I delete a space before "One" and "This".)

Copy link
Member

@jackysp jackysp Oct 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use a union priority order, how about

NO_PRIORITY | LOW_PRIORITY | DELAYED | HIGH_PRIORITY

or

LOW_PRIORITY | DELAYED | HIGH_PRIORITY | NO_PRIORITY


Note that 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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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


### join-concurrency

- The goroutine number when the `join-concurrency` runs `join`
Expand Down
7 changes: 7 additions & 0 deletions sql/tidb-specific.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | GLOBAL
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is a session-only variable though it works on the server level. GLOBAL variable will work on all TiDB servers.

- 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 (or TiDB server) that is performing OLAP queries receives lower priority than users performing OLTP queries.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • 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 (or TiDB server) that is performing OLAP queries receives lower priority than users performing OLTP queries.

- You can set the value of this variable to `PRIORITY_LOW`, `NO_PRIORITY` or `PRIORITY_HIGH`.
Copy link
Member

@jackysp jackysp Oct 8, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's better to use

`NO_PRIORITY`, `LOW_PRIORITY`, `DELAYED` or `HIGH_PRIORITY`

tidb_force_priority uses SQL priority options as its available values which is not the same as tidb_ddl_reorg_priority does.


## 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.
Expand Down