Sign In Try Free

TiDB Configuration File

The TiDB configuration file supports more options than command-line parameters. You can download the default configuration fileconfig.toml.exampleand rename it toconfig.toml。This document describes only the options that are not involved incommand line options

split-table

  • 决定创建一个环保总局rate Region for each table.
  • Default value:true
  • It is recommended to set it tofalseif you need to create a large number of tables (for example, more than 100 thousand tables).

tidb-max-reuse-chunkNew in v6.4.0

  • Controls the maximum cached chunk objects of chunk allocation. Setting this configuration item to too large a value might increase the risk of OOM.
  • Default value:64
  • Minimum value:0
  • Maximum value:2147483647

tidb-max-reuse-columnNew in v6.4.0

  • Controls the maximum cached column objects of chunk allocation. Setting this configuration item to too large a value might increase the risk of OOM.
  • Default value:256
  • Minimum value:0
  • Maximum value:2147483647

token-limit

  • The number of sessions that can execute requests concurrently.
  • Type: Integer
  • Default value:1000
  • Minimum value:1
  • Maximum Value (64-bit platforms):18446744073709551615
  • Maximum Value (32-bit platforms):4294967295

temp-dirNew in v6.3.0

  • File system location used by TiDB to store temporary data. If a feature requires local storage in TiDB nodes, TiDB stores the corresponding temporary data in this location.
  • When creating an index, iftidb_ddl_enable_fast_reorgis enabled, data that needs to be backfilled for a newly created index will be at first stored in the TiDB local temporary directory, and then imported into TiKV in batches, thus accelerating the index creation.
  • Default value:"/tmp/tidb"

oom-use-tmp-storage

  • 控制是否启用临时存储for some operators when a single SQL statement exceeds the memory quota specified by the system variabletidb_mem_quota_query
  • Default value:true

tmp-storage-path

  • Specifies the temporary storage path for some operators when a single SQL statement exceeds the memory quota specified by the system variabletidb_mem_quota_query
  • Default value:/_tidb/MC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=/tmp-storageMC4wLjAuMDo0MDAwLzAuMC4wLjA6MTAwODA=is theBase64encoding result of:/:
  • This configuration takes effect only when the system variabletidb_enable_tmp_storage_on_oomisON

tmp-storage-quota

  • Specifies the quota for the storage intmp-storage-path。The unit is byte.
  • When a single SQL statement uses a temporary disk and the total volume of the temporary disk of the TiDB server exceeds this configuration value, the current SQL operation is cancelled and theOut of Global Storage Quota!error is returned.
  • When the value of this configuration is smaller than0, the above check and limit do not apply.
  • Default value:-1
  • When the remaining available storage intmp-storage-pathis lower than the value defined bytmp-storage-quota, the TiDB server reports an error when it is started, and exits.

lease

  • The timeout of the DDL lease.
  • Default value:45s
  • Unit: second

compatible-kill-query

  • Determines whether to set theKILLstatement to be MySQL compatible.
  • Default value:false
  • compatible-kill-querytakes effect only whenenable-global-killis set tofalse
  • Whenenable-global-killisfalse,compatible-kill-querycontrols whether you need to append theTIDBkeyword when killing a query.
    • Whencompatible-kill-queryisfalse, the behavior ofKILL xxxin TiDB is different from that in MySQL. To kill a query in TiDB, you need to append theTIDBkeyword, such asKILL TIDB xxx
    • Whencompatible-kill-queryistrue, to kill a query in TiDB, there is no need to append theTIDBkeyword. It isSTRONGLY NOT RECOMMENDEDto setcompatible-kill-querytotruein your configuration file UNLESS you are certain that clients will be always connected to the same TiDB instance. This is because pressingControl+Cin the default MySQL client opens a new connection in whichKILLis executed. If there is a proxy between the client and the TiDB cluster, the new connection might be routed to a different TiDB instance, which possibly kills a different session by mistake.
  • Whenenable-global-killistrue,KILL xxxandKILL TIDB xxxhave the same effect, but usingControl+Cto kill a query is not supported.
  • For more information about theKILLstatement, seeKILL [TIDB]

check-mb4-value-in-utf8

  • Determines whether to enable theutf8mb4character check. When this feature is enabled, if the character set isutf8and themb4characters are inserted inutf8, an error is returned.
  • Default value:false
  • Since v6.1.0, whether to enable theutf8mb4character check is determined by the TiDB configuration iteminstance.tidb_check_mb4_value_in_utf8or the system variabletidb_check_mb4_value_in_utf8check-mb4-value-in-utf8still takes effect. But if bothcheck-mb4-value-in-utf8andinstance.tidb_check_mb4_value_in_utf8are set, the latter takes effect.

treat-old-version-utf8-as-utf8mb4

  • Determines whether to treat theutf8character set in old tables asutf8mb4
  • Default value:true

alter-primary-key(Deprecated)

  • Determines whether to add or remove the primary key constraint to or from a column.
  • Default value:false
  • With this default setting, adding or removing the primary key constraint is not supported. You can enable this feature by settingalter-primary-keytotrue。However, if a table already exists before the switch is on, and the data type of its primary key column is an integer, dropping the primary key from the column is not possible even if you set this configuration item totrue

server-version

  • Modifies the version string returned by TiDB in the following situations:
    • When the built-inVERSION()function is used.
    • When TiDB establishes the initial connection to the client and returns the initial handshake packet with version string of the server. For details, seeMySQL Initial Handshake Packet
  • Default value: ""
  • By default, the format of the TiDB version string is5.7.${mysql_latest_minor_version}-TiDB-${tidb_version}

repair-mode

  • Determines whether to enable the untrusted repair mode. When therepair-modeis set totrue, bad tables in therepair-table-listcannot be loaded.
  • Default value:false
  • Therepairsyntax is not supported by default. This means that all tables are loaded when TiDB is started.

repair-table-list

  • repair-table-listis only valid whenrepair-modeis set totruerepair-table-listis a list of bad tables that need to be repaired in an instance. An example of the list is:["db.table1","db.table2"...]
  • Default value: []
  • The list is empty by default. This means that there are no bad tables that need to be repaired.

new_collations_enabled_on_first_bootstrap

  • Enables or disables the new collation support.
  • Default value:true
  • Note: This configuration takes effect only for the TiDB cluster that is first initialized. After the initialization, you cannot use this configuration item to enable or disable the new collation support.

max-server-connections

  • The maximum number of concurrent client connections allowed in TiDB. It is used to control resources.
  • Default value:0
  • By default, TiDB does not set limit on the number of concurrent client connections. When the value of this configuration item is greater than0and the number of actual client connections reaches this value, the TiDB server rejects new client connections.
  • Since v6.2.0, the TiDB configuration iteminstance.max_connectionsor the system variablemax_connectionsis used to set the maximum number of concurrent client connections allowed in TiDB.max-server-connectionsstill takes effect. But ifmax-server-connectionsandinstance.max_connectionsare set at the same time, the latter takes effect.

max-index-length

  • Sets the maximum allowable length of the newly created index.
  • Default value:3072
  • Unit: byte
  • Currently, the valid value range is(3072年,3072 * 4)。MySQL and TiDB (version < v3.0.11) do not have this configuration item, but both limit the length of the newly created index. This limit in MySQL is3072。In TiDB (version =< 3.0.7), this limit is3072*4。In TiDB (3.0.7 < version < 3.0.11), this limit is3072。This configuration is added to be compatible with MySQL and earlier versions of TiDB.

table-column-count-limitNew in v5.0

  • Sets the limit on the number of columns in a single table.
  • Default value:1017
  • Currently, the valid value range is[1017, 4096]

index-limitNew in v5.0

  • Sets the limit on the number of indexes in a single table.
  • Default value:64
  • Currently, the valid value range is[64, 512]

enable-telemetryNew in v4.0.2

  • Enables or disables the telemetry collection in TiDB.
  • Default value:false
  • When this configuration is set totrueon a TiDB instance, the telemetry collection in this TiDB instance is enabled and thetidb_enable_telemetrysystem variable takes effect.
  • When this configuration is set tofalseon all TiDB instances, the telemetry collection in TiDB is disabled and thetidb_enable_telemetrysystem variable does not take effect. SeeTelemetryfor details.

enable-tcp4-onlyNew in v5.0

  • Enables or disables listening on TCP4 only.
  • Default value:false
  • Enabling this option is useful when TiDB is used with LVS for load balancing because thereal client IP from the TCP headercan be correctly parsed by the "tcp4" protocol.

enable-enum-length-limitNew in v5.0

  • Determines whether to limit the maximum length of a singleENUMelement and a singleSETelement.
  • Default value:true
  • When this configuration value istrue, the maximum length of a singleENUMelement and a singleSETelement is 255 characters, which is compatible withMySQL 8.0。When this configuration value isfalse, there is no limit on the length of a single element, which is compatible with TiDB (earlier than v5.0).

graceful-wait-before-shutdownNew in v5.0

  • Specifies the number of seconds that TiDB waits when you shut down the server, which allows the clients to disconnect.
  • Default value:0
  • When TiDB is waiting for shutdown (in the grace period), the HTTP status will indicate a failure, which allows the load balancers to reroute traffic.

enable-global-killNew in v6.1.0

  • Controls whether to enable the Global Kill (terminating queries or connections across instances) feature.
  • Default value:true
  • When the value istrue, bothKILLandKILL TIDBstatements can terminate queries or connections across instances so you do not need to worry about erroneously terminating queries or connections. When you use a client to connect to any TiDB instance and execute theKILLorKILL TIDBstatement, the statement will be forwarded to the target TiDB instance. If there is a proxy between the client and the TiDB cluster, theKILLandKILL TIDBstatements will also be forwarded to the target TiDB instance for execution. Currently, using the MySQL command linectrl+cto terminate a query or connection in TiDB is not supported whenenable-global-killistrue。更多的信息KILLstatement, seeKILL

initialize-sql-fileNew in v6.6.0

  • Specifies the SQL script to be executed when the TiDB cluster is started for the first time.
  • Default value:""
  • All SQL statements in this script are executed with the highest privilege without any privilege check. If the specified SQL script fails to execute, the TiDB cluster might fail to start.
  • This configuration item is used to perform such operations as modifying the value of a system variable, creating a user, or granting privileges.

enable-forwardingNew in v5.0.0

  • Controls whether the PD client and TiKV client in TiDB forward requests to the leader via the followers in the case of possible network isolation.
  • Default value:false
  • If the environment might have isolated network, enabling this parameter can reduce the window of service unavailability.
  • If you cannot accurately determine whether isolation, network interruption, or downtime has occurred, using this mechanism has the risk of misjudgment and causes reduced availability and performance. If network failure has never occurred, it is not recommended to enable this parameter.

enable-table-lockNew in v4.0.0

  • Controls whether to enable the table lock feature.
  • Default value:false
  • The table lock is used to coordinate concurrent access to the same table among multiple sessions. Currently, theREAD,WRITE, andWRITE LOCALlock types are supported. When the configuration item is set tofalse, executing theLOCK TABLESorUNLOCK TABLESstatement does not take effect and returns the "LOCK/UNLOCK TABLES is not supported" warning. For more information, seeLOCK TABLESandUNLOCK TABLES

labels

  • Specify server labels. For example,{ zone = "us-west-1", dc = "dc1", rack = "rack1", host = "tidb1" }
  • Default value:{}

Log

Configuration items related to log.

level

  • Specifies the log output level.
  • Value options:debug,info,warn,error, andfatal
  • Default value:info

format

  • Specifies the log output format.
  • Value options:jsonandtext
  • Default value:text

enable-timestamp

  • Determines whether to enable timestamp output in the log.
  • Default value:null
  • If you set the value tofalse, the log does not output timestamp.

enable-slow-log

  • Determines whether to enable the slow query log.
  • Default value:true
  • To enable the slow query log, setenable-slow-logtotrue。Otherwise, set it tofalse
  • Since v6.1.0, whether to enable slow query log is determined by the TiDB configuration iteminstance.tidb_enable_slow_logor the system variabletidb_enable_slow_logenable-slow-logstill takes effect. But ifenable-slow-logandinstance.tidb_enable_slow_logare set at the same time, the latter takes effect.

slow-query-file

  • The file name of the slow query log.
  • Default value:tidb-slow.log
  • The format of the slow log is updated in TiDB v2.1.8, so the slow log is output to the slow log file separately. In versions before v2.1.8, this variable is set to "" by default.
  • After you set it, the slow query log is output to this file separately.

slow-threshold

  • Outputs the threshold value of consumed time in the slow log.
  • Default value:300
  • Unit: Milliseconds
  • If the value in a query is larger than the default value, it is a slow query and is output to the slow log.
  • Since v6.1.0, the threshold value of consumed time in the slow log is specified by the TiDB configuration iteminstance.tidb_slow_log_thresholdor the system variabletidb_slow_log_thresholdslow-thresholdstill takes effect. But ifslow-thresholdandinstance.tidb_slow_log_thresholdare set at the same time, the latter takes effect.

record-plan-in-slow-log

  • Determines whether to record execution plans in the slow log.
  • Default value:1
  • Since v6.1.0, whether to record execution plans in the slow log is determined by the TiDB configuration iteminstance.tidb_record_plan_in_slow_logor the system variabletidb_record_plan_in_slow_logrecord-plan-in-slow-logstill takes effect. But ifrecord-plan-in-slow-logandinstance.tidb_record_plan_in_slow_logare set at the same time, the latter takes effect.

expensive-threshold

  • Outputs the threshold value of the number of rows for theexpensiveoperation.
  • Default value:10000
  • When the number of query rows (including the intermediate results based on statistics) is larger than this value, it is anexpensiveoperation and outputs log with the[EXPENSIVE_QUERY]prefix.

timeoutNew in v7.1.0

  • Sets the timeout for log-writing operations in TiDB. In case of a disk failure that prevents logs from being written, this configuration item can trigger the TiDB process to panic instead of hang.
  • Default value:0, indicating no timeout is set.
  • Unit: second
  • In some user scenarios, TiDB logs might be stored on hot-pluggable or network-attached disks, which might become permanently unavailable. In these cases, TiDB cannot recover automatically from such disaster and the log-writing operations will be permanently blocked. Although the TiDB process might seem to be running, it does not respond to any requests. This configuration item is designed to handle such situations.

log.file

Configuration items related to log files.

filename

  • The file name of the general log file.
  • Default value: ""
  • If you set it, the log is output to this file.

max-size

  • The size limit of the log file.
  • Default value: 300
  • Unit: MB
  • The maximum value is 4096.

max-days

  • The maximum number of days that the log is retained.
  • Default value:0
  • The log is retained by default. If you set the value, the expired log is cleaned up aftermax-days

max-backups

  • The maximum number of retained logs.
  • Default value:0
  • All the log files are retained by default. If you set it to7, seven log files are retained at maximum.

Security

Configuration items related to security.

enable-sem

  • Enables the Security Enhanced Mode (SEM).
  • Default value:false
  • The status of SEM is available via the system variabletidb_enable_enhanced_security

ssl-ca

  • The file path of the trusted CA certificate in the PEM format.
  • Default value: ""
  • If you set this option and--ssl-cert,--ssl-keyat the same time, TiDB authenticates the client certificate based on the list of trusted CAs specified by this option when the client presents the certificate. If the authentication fails, the connection is terminated.
  • If you set this option but the client does not present the certificate, the secure connection continues without client certificate authentication.

ssl-cert

  • The file path of the SSL certificate in the PEM format.
  • Default value: ""
  • If you set this option and--ssl-keyat the same time, TiDB allows (but not forces) the client to securely connect to TiDB using TLS.
  • If the specified certificate or private key is invalid, TiDB starts as usual but cannot receive secure connection.

ssl-key

  • The file path of the SSL certificate key in the PEM format, that is, the private key of the certificate specified by--ssl-cert
  • Default value: ""
  • Currently, TiDB does not support loading the private keys protected by passwords.

cluster-ssl-ca

  • The CA root certificate used to connect TiKV or PD with TLS.
  • Default value: ""

cluster-ssl-cert

  • The path of the SSL certificate file used to connect TiKV or PD with TLS.
  • Default value: ""

cluster-ssl-key

  • The path of the SSL private key file used to connect TiKV or PD with TLS.
  • Default value: ""

spilled-file-encryption-method

  • Determines the encryption method used for saving the spilled files to disk.
  • Default value:"plaintext", which disables encryption.
  • Optional values:"plaintext"and"aes128-ctr"

auto-tls

  • Determines whether to automatically generate the TLS certificates on startup.
  • Default value:false

tls-version

  • Set the minimum TLS version for MySQL Protocol connections.
  • Default value: "", which allows TLSv1.1 or higher.
  • Optional values:"TLSv1.0","TLSv1.1","TLSv1.2"and"TLSv1.3"

auth-token-jwksNew in v6.4.0

  • Set the local file path of the JSON Web Key Sets (JWKS) for thetidb_auth_tokenauthentication method.
  • Default value:""

auth-token-refresh-intervalNew in v6.4.0

  • Set the JWKS refresh interval for thetidb_auth_tokenauthentication method.
  • Default value:1h

disconnect-on-expired-passwordNew in v6.5.0

  • Determines whether TiDB disconnects the client connection when the password is expired.
  • Default value:true
  • Optional values:true,false
  • If you set it totrue, the client connection is disconnected when the password is expired. If you set it tofalse, the client connection is restricted to the "sandbox mode" and the user can only execute the password reset operation.

session-token-signing-certNew in v6.4.0

  • Default value: ""

session-token-signing-keyNew in v6.4.0

  • Default value: ""

Performance

Configuration items related to performance.

max-procs

  • The number of CPUs used by TiDB.
  • Default value:0
  • The default0indicates using all the CPUs on the machine. You can also set it to n, and then TiDB uses n CPUs.

server-memory-quotaNew in v4.0.9

  • The memory usage limit of tidb-server instances.
  • Default value:0(in bytes), which means no memory limit.

max-txn-ttl

  • The longest time that a single transaction can hold locks. If this time is exceeded, the locks of a transaction might be cleared by other transactions so that this transaction cannot be successfully committed.
  • Default value:3600000
  • Unit: Millisecond
  • The transaction that holds locks longer than this time can only be committed or rolled back. The commit might not be successful.

stmt-count-limit

  • The maximum number of statements allowed in a single TiDB transaction.
  • Default value:5000
  • If a transaction does not roll back or commit after the number of statements exceedsstmt-count-limit, TiDB returns thestatement count 5001 exceeds the transaction limitation, autocommit = falseerror. This configuration takes effectonlyin the retryable optimistic transaction. If you use the pessimistic transaction or have disabled the transaction retry, the number of statements in a transaction is not limited by this configuration.

txn-entry-size-limitNew in v5.0

  • The size limit of a single row of data in TiDB.
  • Default value:6291456(in bytes)
  • The size limit of a single key-value record in a transaction. If the size limit is exceeded, TiDB returns theentry too largeerror. The maximum value of this configuration item does not exceed125829120(120 MB).
  • Note that TiKV has a similar limit. If the data size of a single write request exceedsraft-entry-max-size默认是8 MB, TiKV拒绝过程s this request. When a table has a row of large size, you need to modify both configurations at the same time.
  • The default value ofmax_allowed_packet(the maximum size of a packet for the MySQL protocol) is 67108864 (64 MiB). If a row is larger thanmax_allowed_packet, the row gets truncated.
  • The default value oftxn-total-size-limit(the size limit of a single transaction in TiDB) is 100 MiB. If you increase thetxn-entry-size-limitvalue to be over 100 MiB, you need to increase thetxn-total-size-limitvalue accordingly.

txn-total-size-limit

  • The size limit of a single transaction in TiDB.
  • Default value:104857600(in bytes)
  • In a single transaction, the total size of key-value records cannot exceed this value. The maximum value of this parameter is1099511627776(1 TB). Note that if you have used the binlog to serve the downstream consumer Kafka (such as thearbitercluster), the value of this parameter must be no more than1073741824(1 GB). This is because 1 GB is the upper limit of a single message size that Kafka can process. Otherwise, an error is returned if this limit is exceeded.
  • In TiDB v6.5.0 and later versions, this configuration is no longer recommended. The memory size of a transaction will be accumulated into the memory usage of the session, and thetidb_mem_quota_queryvariable will take effect when the session memory threshold is exceeded. To be compatible with previous versions, this configuration works as follows when you upgrade from an earlier version to TiDB v6.5.0 or later:
    • If this configuration is not set or is set to the default value (104857600), after an upgrade, the memory size of a transaction will be accumulated into the memory usage of the session, and thetidb_mem_quota_queryvariable will take effect.
    • If this configuration is not defaulted (104857600), it still takes effect and its behavior on controling the size of a single transaction remains unchanged before and after the upgrade. This means that the memory size of the transaction is not controlled by thetidb_mem_quota_queryvariable.

tcp-keep-alive

  • Determines whether to enablekeepalivein the TCP layer.
  • Default value:true

tcp-no-delay

  • Determines whether to enable TCP_NODELAY at the TCP layer. After it is enabled, TiDB disables the Nagle algorithm in the TCP/IP protocol and allows sending small data packets to reduce network latency. This is suitable for latency-sensitive applications with a small transmission volume of data.
  • Default value:true

cross-join

  • Default value:true
  • TiDB supports executing theJOINstatement without any condition (theWHEREfield) of both sides tables by default; if you set the value tofalse, the server refuses to execute when such aJOINstatement appears.

stats-lease

  • The time interval of reloading statistics, updating the number of table rows, checking whether it is needed to perform the automatic analysis, using feedback to update statistics and loading statistics of columns.
  • Default value:3s
    • At intervals ofstats-leasetime, TiDB checks the statistics for updates and updates them to the memory if updates exist.
    • At intervals of20 * stats-leasetime, TiDB updates the total number of rows generated by DML and the number of modified rows to the system table.
    • At intervals ofstats-lease, TiDB checks for tables and indexes that need to be automatically analyzed.
    • At intervals ofstats-lease, TiDB checks for column statistics that need to be loaded to the memory.
    • At intervals of200 * stats-lease, TiDB writes the feedback cached in the memory to the system table.
    • At intervals of5 * stats-lease, TiDB reads the feedback in the system table, and updates the statistics cached in the memory.
  • Whenstats-leaseis set to 0s, TiDB periodically reads the feedback in the system table, and updates the statistics cached in the memory every three seconds. But TiDB no longer automatically modifies the following statistics-related system tables:
    • mysql.stats_meta: TiDB no longer automatically records the number of table rows that are modified by the transaction and updates it to this system table.
    • mysql.stats_histograms/mysql.stats_bucketsandmysql.stats_top_n: TiDB no longer automatically analyzes and proactively updates statistics.
    • mysql.stats_feedback: TiDB no longer updates the statistics of the tables and indexes according to a part of statistics returned by the queried data.

pseudo-estimate-ratio

  • The ratio of (number of modified rows)/(total number of rows) in a table. If the value is exceeded, the system assumes that the statistics have expired and the pseudo statistics will be used.
  • Default value:0.8
  • The minimum value is0and the maximum value is1

force-priority

  • Sets the priority for all statements.
  • Default value:NO_PRIORITY
  • Value options: The default valueNO_PRIORITYmeans that the priority for statements is not forced to change. Other options areLOW_PRIORITY,DELAYED, andHIGH_PRIORITYin ascending order.
  • Since v6.1.0, the priority for all statements is determined by the TiDB configuration iteminstance.tidb_force_priorityor the system variabletidb_force_priorityforce-prioritystill takes effect. But ifforce-priorityandinstance.tidb_force_priorityare set at the same time, the latter takes effect.

distinct-agg-push-down

  • 确定优化器执行打开ation that pushes down the aggregation function withDistinct(such asselect count(distinct a) from t) to Coprocessors.
  • Default:false
  • This variable is the initial value of the system variabletidb_opt_distinct_agg_push_down

enforce-mpp

  • Determines whether to ignore the optimizer's cost estimation and to forcibly use TiFlash's MPP mode for query execution.
  • Default value:false
  • This configuration item controls the initial value oftidb_enforce_mpp。For example, when this configuration item is set totrue, the default value oftidb_enforce_mppisON

enable-stats-cache-mem-quotaNew in v6.1.0

  • Controls whether to enable the memory quota for the statistics cache.
  • Default value:false

stats-load-concurrencyNew in v5.4.0

  • The maximum number of columns that the TiDB synchronously loading statistics feature can process concurrently.
  • Default value:5
  • Currently, the valid value range is[1, 128]

stats-load-queue-sizeNew in v5.4.0

  • The maximum number of column requests that the TiDB synchronously loading statistics feature can cache.
  • Default value:1000
  • Currently, the valid value range is[1, 100000]

lite-init-statsNew in v7.1.0

  • Controls whether to use lightweight statistics initialization during TiDB startup.
  • Default value: false
  • When the value oflite-init-statsistrue, statistics initialization does not load any histogram, TopN, or Count-Min Sketch of indexes or columns into memory. When the value oflite-init-statsisfalse, statistics initialization loads histograms, TopN, and Count-Min Sketch of indexes and primary keys into memory but does not load any histogram, TopN, or Count-Min Sketch of non-primary key columns into memory. When the optimizer needs the histogram, TopN, and Count-Min Sketch of a specific index or column, the necessary statistics are loaded into memory synchronously or asynchronously (controlled bytidb_stats_load_sync_wait).
  • Settinglite-init-statstotruespeeds up statistics initialization and reduces TiDB memory usage by avoiding unnecessary statistics loading. For details, seeLoad statistics

force-init-statsNew in v7.1.0

  • Controls whether to wait for statistics initialization to finish before providing services during TiDB startup.
  • Default value: false
  • When the value offorce-init-statsistrue, TiDB needs to wait until statistics initialization is finished before providing services upon startup. If there are a large number of tables and partitions, settingforce-init-statstotruemight prolong the time it takes for TiDB to start providing services.
  • When the value offorce-init-statsisfalse, TiDB can still provide services before statistics initialization is finished, but the optimizer uses pseudo statistics to make decisions, which might result in suboptimal execution plans.

opentracing

Configuration items related to opentracing.

enable

  • Enables opentracing to trace the call overhead of some TiDB components. Note that enabling opentracing causes some performance loss.
  • Default value:false

rpc-metrics

  • Enables RPC metrics.
  • Default value:false

opentracing.sampler

Configuration items related to opentracing.sampler.

type

  • Specifies the type of the opentracing sampler. The string value is case-insensitive.
  • Default value:"const"
  • Value options:"const","probabilistic","ratelimiting","remote"

param

  • The parameter of the opentracing sampler.
    • For theconsttype, the value can be0or1, which indicates whether to enable theconstsampler.
    • For theprobabilistictype, the parameter specifies the sampling probability, which can be a float number between0and1
    • For theratelimitingtype, the parameter specifies the number of spans sampled per second.
    • For theremotetype, the parameter specifies the sampling probability, which can be a float number between0and1
  • Default value:1.0

sampling-server-url

  • The HTTP URL of the jaeger-agent sampling server.
  • Default value:""

max-operations

  • The maximum number of operations that the sampler can trace. If an operation is not traced, the default probabilistic sampler is used.
  • Default value:0

sampling-refresh-interval

  • Controls the frequency of polling the jaeger-agent sampling policy.
  • Default value:0

opentracing.reporter

Configuration items related to opentracing.reporter.

queue-size

  • The queue size with which the reporter records spans in memory.
  • Default value:0

buffer-flush-interval

  • The interval at which the reporter flushes the spans in memory to the storage.
  • Default value:0

log-spans

  • Determines whether to print the log for all submitted spans.
  • Default value:false

local-agent-host-port

  • The address at which the reporter sends spans to the jaeger-agent.
  • Default value:""

tikv-client

grpc-connection-count

  • The maximum number of connections established with each TiKV.
  • Default value:4

grpc-keepalive-time

  • Thekeepalivetime interval of the RPC connection between TiDB and TiKV nodes. If there is no network packet within the specified time interval, the gRPC client executespingcommand to TiKV to see if it is alive.
  • Default:10
  • Unit: second

grpc-keepalive-timeout

  • The timeout of the RPCkeepalivecheck between TiDB and TiKV nodes.
  • Default value:3
  • Unit: second

grpc-compression-type

  • Specifies the compression type used for data transfer between TiDB and TiKV nodes. The default value is"none", which means no compression. To enable the gzip compression, set this value to"gzip"
  • Default value:"none"
  • Value options:"none","gzip"

commit-timeout

  • The maximum timeout when executing a transaction commit.
  • Default value:41s
  • It is required to set this value larger than twice of the Raft election timeout.

max-batch-size

  • The maximum number of RPC packets sent in batch. If the value is not0, theBatchCommandsAPI is used to send requests to TiKV, and the RPC latency can be reduced in the case of high concurrency. It is recommended that you do not modify this value.
  • Default value:128

max-batch-wait-time

  • Waits formax-batch-wait-timeto encapsulate the data packets into a large packet in batch and send it to the TiKV node. It is valid only when the value oftikv-client.max-batch-sizeis greater than0。It is recommended not to modify this value.
  • Default value:0
  • Unit: nanoseconds

batch-wait-size

  • The maximum number of packets sent to TiKV in batch. It is recommended not to modify this value.
  • Default value:8
  • If the value is0, this feature is disabled.

overload-threshold

  • The threshold of the TiKV load. If the TiKV load exceeds this threshold, morebatchpackets are collected to relieve the pressure of TiKV. It is valid only when the value oftikv-client.max-batch-sizeis greater than0。It is recommended not to modify this value.
  • Default value:200

tikv-client.copr-cacheNew in v4.0.0

This section introduces configuration items related to the Coprocessor Cache feature.

capacity-mb

  • The total size of the cached data. When the cache space is full, old cache entries are evicted. When the value is0.0, the Coprocessor Cache feature is disabled.
  • Default value:1000.0
  • Unit: MB
  • Type: Float

txn-local-latches

Configuration related to the transaction latch. It is recommended to enable it when many local transaction conflicts occur.

enabled

  • Determines whether to enable the memory lock of transactions.
  • Default value:false

capacity

  • 相对应的槽数散列,utomatically adjusts upward to an exponential multiple of 2. Each slot occupies 32 Bytes of memory. If set too small, it might result in slower running speed and poor performance in the scenario where data writing covers a relatively large range (such as importing data).
  • Default value:2048000

binlog

Configurations related to TiDB Binlog.

enable

  • Enables or disables binlog.
  • Default value:false

write-timeout

  • The timeout of writing binlog into Pump. It is not recommended to modify this value.
  • Default:15s
  • unit: second

ignore-error

  • Determines whether to ignore errors occurred in the process of writing binlog into Pump. It is not recommended to modify this value.
  • Default value:false
  • When the value is set totrueand an error occurs, TiDB stops writing binlog and add1to the count of thetidb_server_critical_error_totalmonitoring item. When the value is set tofalse, the binlog writing fails and the entire TiDB service is stopped.

binlog-socket

  • The network address to which binlog is exported.
  • Default value: ""

strategy

  • The strategy of Pump selection when binlog is exported. Currently, only thehashandrangemethods are supported.
  • Default value:range

status

Configuration related to the status of TiDB service.

report-status

  • Enables or disables the HTTP API service.
  • Default value:true

record-db-qps

  • Determines whether to transmit the database-related QPS metrics to Prometheus.
  • Default value:false

pessimistic-txn

For pessimistic transaction usage, refer toTiDB Pessimistic Transaction Mode

max-retry-count

  • The maximum number of retries of each statement in pessimistic transactions. If the number of retries exceeds this limit, an error occurs.
  • Default value:256

deadlock-history-capacity

  • The maximum number of deadlock events that can be recorded in theINFORMATION_SCHEMA.DEADLOCKStable of a single TiDB server. If this table is in full volume and an additional deadlock event occurs, the earliest record in the table will be removed to make place for the newest error.
  • Default value:10
  • Minimum value:0
  • Maximum value:10000

deadlock-history-collect-retryable

pessimistic-auto-commitNew in v6.0.0

  • Determines the transaction mode that the auto-commit transaction uses when the pessimistic transaction mode is globally enabled (tidb_txn_mode='pessimistic').默认情况下,即使悲观事务mode is globally enabled, the auto-commit transaction still uses the optimistic transaction mode. After enablingpessimistic-auto-commit(set totrue), the auto-commit transaction also uses pessimistic mode, which is consistent with the other explicitly committed pessimistic transactions.
  • For scenarios with conflicts, after enabling this configuration, TiDB includes auto-commit transactions into the global lock-waiting management, which avoids deadlocks and mitigates the latency spike brought by deadlock-causing conflicts.
  • For scenarios with no conflicts, if there are many auto-commit transactions (the specific number is determined by the real scenarios. For example, the number of auto-commit transactions accounts for more than half of the total number of applications), and a single transaction operates a large data volume, enabling this configuration causes performance regression. For example, the auto-commitINSERT INTO SELECTstatement.
  • Default value:false

constraint-check-in-place-pessimisticNew in v6.4.0

isolation-read

Configuration items related to read isolation.

engines

  • Controls from which engine TiDB allows to read data.
  • Default value:["tikv", "tiflash", "tidb"], indicating that the engine is automatically selected by the optimizer.
  • Value options: Any combinations of "tikv", "tiflash", and "tidb", for example,["tikv", "tidb"]or["tiflash", "tidb"]

instance

tidb_enable_collect_execution_info

  • This configuration controls whether to record the execution information of each operator in the slow query log.
  • Default value:true
  • Before v6.1.0, this configuration is set byenable-collect-execution-info

tidb_enable_slow_log

  • This configuration is used to control whether to enable the slow log feature.
  • Default value:true
  • Value options:trueorfalse
  • Before v6.1.0, this configuration is set byenable-slow-log

tidb_slow_log_threshold

  • This configuration is used to output the threshold value of the time consumed by the slow log. When the time consumed by a query is larger than this value, this query is considered as a slow log and its log is output to the slow query log.
  • Default value:300
  • Range:[-1, 9223372036854775807]
  • Unit: Milliseconds
  • Before v6.1.0, this configuration is set byslow-threshold

tidb_expensive_query_time_threshold

  • This configuration is used to set the threshold value that determines whether to print expensive query logs. The difference between expensive query logs and slow query logs is:
    • Slow logs are printed after the statement is executed.
    • Expensive query logs print the statements that are being executed, with execution time exceeding the threshold value, and their related information.
  • Default value:60
  • Range:[10, 2147483647]
  • Unit: Seconds
  • Before v5.4.0, this configuration is set byexpensive-threshold

tidb_record_plan_in_slow_log

  • This configuration is used to control whether to include the execution plan of slow queries in the slow log.
  • Default value:1
  • Value options:1(enabled, default) or0(disabled).
  • The value of this configuration will initialize the value of system variabletidb_record_plan_in_slow_log
  • Before v6.1.0, this configuration is set byrecord-plan-in-slow-log

tidb_force_priority

  • This configuration is used to change the default priority for statements executed on a TiDB server.
  • Default value:NO_PRIORITY
  • The default valueNO_PRIORITYmeans that the priority for statements is not forced to change. Other options areLOW_PRIORITY,DELAYED, andHIGH_PRIORITYin ascending order.
  • Before v6.1.0, this configuration is set byforce-priority

max_connections

  • The maximum number of connections permitted for a single TiDB instance. It can be used for resources control.
  • Default value:0
  • Range:[0, 100000]
  • The default value0means no limit. When the value of this variable is larger than0, and the number of connections reaches the value, the TiDB server will reject new connections from clients.
  • The value of this configuration will initialize the value of system variablemax_connections
  • Before v6.2.0, this configuration is set bymax-server-connections

tidb_enable_ddl

  • This configuration controls whether the corresponding TiDB instance can become a DDL owner or not.
  • Default value:true
  • Possible values:OFF,ON
  • The value of this configuration will initialize the value of the system variabletidb_enable_ddl
  • Before v6.3.0, this configuration is set byrun-ddl

tidb_stmt_summary_enable_persistentNew in v6.6.0

  • Controls whether to enable statements summary persistence.
  • Default value:false
  • For more details, seePersist statements summary

tidb_stmt_summary_filenameNew in v6.6.0

  • When statements summary persistence is enabled, this configuration specifies the file to which persistent data is written.
  • Default value:tidb-statements.log

tidb_stmt_summary_file_max_daysNew in v6.6.0

  • When statements summary persistence is enabled, this configuration specifies the maximum number of days to keep persistent data files.
  • Default value:3
  • Unit: day
  • You can adjust the value based on the data retention requirements and disk space usage.

tidb_stmt_summary_file_max_sizeNew in v6.6.0

  • When statements summary persistence is enabled, this configuration specifies the maximum size of a persistent data file.
  • Default value:64
  • Unit: MiB
  • You can adjust the value based on the data retention requirements and disk space usage.

tidb_stmt_summary_file_max_backupsNew in v6.6.0

  • When statements summary persistence is enabled, this configuration specifies the maximum number of data files that can be persisted.0means no limit on the number of files.
  • Default value:0
  • You can adjust the value based on the data retention requirements and disk space usage.

proxy-protocol

Configuration items related to the PROXY protocol.

networks

  • The list of proxy server's IP addresses allowed to connect to TiDB using thePROXY protocol
  • Default value: ""
  • In general cases, when you access TiDB behind a reverse proxy, TiDB takes the IP address of the reverse proxy server as the IP address of the client. By enabling the PROXY protocol, reverse proxies that support this protocol, such as HAProxy, can pass the real client IP address to TiDB.
  • After configuring this parameter, TiDB allows the configured source IP address to connect to TiDB using the PROXY protocol; if a protocol other than PROXY is used, this connection will be denied. If this parameter is left empty, no IP address can connect to TiDB using the PROXY protocol. The value can be an IP address (192.168.1.50) or CIDR (192.168.1.0/24) with,as the separator.*means any IP addresses.

fallbackableNew in v6.5.1

  • Controls whether to enable the PROXY protocol fallback mode. If this configuration item is set totrue, TiDB can accept clients that belong toproxy-protocol.networksto connect to TiDB without using the PROXY protocol specification or without sending the PROXY protocol header. By default, TiDB only accepts client connections that belong toproxy-protocol.networksand send a PROXY protocol header.
  • Default value:false

experimental

Theexperimentalsection, introduced in v3.1.0, describes the configurations related to the experimental features of TiDB.

allow-expression-indexNew in v4.0.0

  • Controls whether an expression index can be created. Since TiDB v5.2.0, if the function in an expression is safe, you can create an expression index directly based on this function without enabling this configuration. If you want to create an expression index based on other functions, you can enable this configuration, but correctness issues might exist. By querying thetidb_allow_function_for_expression_indexvariable, you can get the functions that are safe to be directly used for creating an expression.
  • Default value:false
Download PDF Request docs changes Ask questions on Discord
Playground
New
One-stop & interactive experience of TiDB's capabilities WITHOUT registration.
Was this page helpful?
Products
TiDB
TiDB Dedicated
TiDB Serverless
Pricing
Get Demo
Get Started
©2023PingCAP. All Rights Reserved.