Author: Duan Bing

TiDB is an open source distributed relational database independently developed by PingCAP. It has the data reliability, availability, security and other features of commercial database, supports online elastic horizontal expansion, is compatible with MySQL protocol and ecology, and innovatively realizes the integration of OLTP and OLAP.

TiDB 3.0 significantly improves the stability of large-scale clusters, which support 150+ storage nodes and 300+TB storage capacity for long-term stable operation. In terms of ease of use, a large number of optimizations were introduced to reduce user operation and maintenance costs, including the introduction of multiple practical system views in Information_Schema, EXPLAIN ANALYZE, SQL Trace, etc. In terms of performance, especially OLTP performance, 3.0 is also significantly improved compared with 2.1, among which TPC-C performance is improved by about 4.5 times, Sysbench performance is improved by about 1.5 times, and IN terms of OLAP, TPC-H 50G Q15 can execute due to View implementation. So far, all 22 tPC-H queries can run normally. New features include window functions, views (experimental features), partitioned tables, plug-in systems, and pessimistic locks (experimental features).

As of the time of publication, TiDB has been running stably in the production environment of 500+ users for a long time, covering finance, insurance, manufacturing, Internet, games and other fields, including transaction, data center, history library and other business scenes. The demands of different business scenarios for relational databases can be described as “a hundred flowers bloom”, but the most fundamental demands for relational databases remain unchanged, such as data reliability, system stability, scalability, security, ease of use and so on. Please follow our steps to find out what surprises TiDB 3.0 has.

1. Improve the stability of large-scale clusters

Compared with version 2.1, 3.0 significantly improves the stability of large-scale clusters. It supports the long-term stable operation of 150+ storage nodes and 300+TB storage capacity in a single cluster. The main optimization points are as follows:

1. Optimize the heartbeat mechanism between Raft copies and adjust the heartbeat frequency according to the activity of regions to reduce the burden of cold data on the cluster.

2. The hotspot scheduling policy supports more parameters, takes higher priorities, and improves the accuracy of hotspot scheduling.

3. Optimize PD scheduling process, provide scheduling flow limiting mechanism, and improve system stability.

4. Added the distributed GC function to improve GC performance, reduce the GC time of large clusters, and improve system stability.

2. Improve the stability of query plans

As we all know, the stability of the database query plan is critical to the business. TiDB 3.0 uses several optimization measures to improve the stability of the query plan, as follows:

1. Add the Fast Analyze function to improve statistics collection speed and reduce cluster resource consumption and impact on services.

2. Add the Incremental Analyze function to improve the collection speed of Incremental index statistics and reduce the consumption of cluster resources and impact on services.

3. Add TopN statistics in Cm-Sketch to alleviate the large estimation caused by cm-Sketch hash conflict, improve the accuracy of cost estimation, and improve the stability of query plan.

4. Skyline Pruning framework was introduced and rules were used to prevent query plans from relying too much on statistical information, alleviate the situation that the selected query plan was not optimal due to the lag of statistical information, and improve the stability of query plans.

5. Added the SQL Plan Management function to manually bind a query Plan if the query Plan is inaccurate, improving the stability of the query Plan.

Iii. Improved system performance: TPC-C performance improved by about 4.5 times, Sysbench performance improved by about 1.5 times

1. OLTP

Compared with version 2.1, Sysbench Point Select, Update Index, Update non-index are improved by about 1.5 times, and TPC-C performance is improved by about 4.5 times. The main optimization points are as follows:

1. TiDB continuously optimizes the SQL executor, including: optimizing NOT EXISTS subquery conversion to anti-semi Join, optimizing Join order selection when multi-table Join, etc.

2. Optimize the Index Join logic, expand the applicable scenarios of Index Join operator and improve the accuracy of cost estimation.

3. TiKV batch receiving and sending function improves TPS of write intensive scenarios by about 7% and read intensive scenarios by about 30%.

4. TiKV optimizes memory management, reduces memory allocation and copying of Iterator Key Bound options, and improves performance by sharing block cache with multiple Column Families to improve cache hit ratio.

5. Titan storage engine plug-in is introduced to improve performance when the Value exceeds 1KB, alleviate RocksDB write magnification problem and reduce disk I/o occupation.

6. TiKV added multi-threaded Raftstore and Apply functions to improve the scalability within a single node, thereby improving the concurrent processing capacity and resource utilization rate within a single node, reducing latency, and greatly improving cluster writing capacity.

2.TiDB Lightning

The performance of TiDB Lightning has been improved by 3 times compared with the beginning of 2019, from 100GB/h to 300GB/h, that is, 28MB/s to 85MB/s. The optimization points are as follows:

1. Improve performance of SQL to KV Pairs and reduce unnecessary overhead.

2. Improve the performance of importing a single table. A single table supports batch import.

3. Improve the data import performance of TiKV-importer and support to import data and indexes separately.

4. Tikv-importer supports the speed limiting function of uploading SST files.

4. Improve system security

RBAC (Role-based Access Control) is one of the most common Access management techniques in commercial systems. The simplest user-role-permission Access Control model can be constructed Based on RBAC. In RBAC, users are associated with roles and permissions are associated with roles. Generally, roles and permissions have many-to-many relationships. Users can obtain permissions of roles by becoming what roles they are, so as to simplify permission management.

IP address whitelist function (enterprise edition feature) : TiDB implements network security access control based on the IP address whitelist. Users can configure access policies based on actual conditions.

Audit Log (Enterprise edition) : The Audit log records operations performed by users on the database. You can perform fault analysis, behavior analysis, and security Audit on the database to obtain data execution status.

Encrypted storage (Enterprise edition feature) : TiDB uses the encryption function of RocksDB to implement the encrypted storage function, ensuring that all data written to disks is encrypted and reducing the risk of data leakage.

Improved the permission check of permission statements, added the ANALYZE, USE, SET GLOBAL, SHOW PROCESSLIST statement permission check.

5. Improve system usability

1. Add SQL slow query to enrich TiDB slow query log contents, such as number of Coprocessor tasks, average/maximum /90% execution/waiting time, and TiKV address with the longest execution/waiting time, simplifying slow query and locating, improving the efficiency of troubleshooting slow query problems, and improving product usability.

2. Added the validity check of system configuration items and optimized system monitoring items to improve product usability.

3. Add statistics on memory usage of TableReader, IndexReader, and IndexLookupReader operators to improve the accuracy of Query memory usage statistics and the efficiency of processing statements that consume large amounts of memory.

4. Formulate log specifications, reconstruct the log system, and unify the log format to facilitate users’ understanding of log content and quantitative analysis of logs using tools.

5. Added the EXPLAIN ANALYZE function to improve the ease of SQL tuning.

6. Added the SQL statement Trace function to facilitate troubleshooting.

7. Added connecting to the database through unix_Socket.

8. Added the function of quickly recovering deleted tables to quickly recover data when data is mistakenly deleted.

6. Enhance HTAP capability

TiDB 3.0 adds a TiFlash component for complex analysis and HTAP scenarios. TiFlash is a column storage system that synchronizes with a row storage system in real time. It has features such as low latency, high performance, and transaction consistency read. Raft protocol is used to store real-time concurrent data from TiKV and convert it into column storage format for persistence to a group of independent nodes, which solves the problems of mixed storage of columns and columns and resource isolation. TiFlash can be used as real-time mirror of TiKV. Real-time mirror can be independent of TiKV. It separates row storage and column storage from physical storage and provides perfect resource isolation scheme and optimal recommended scheme for HTAP scenario. It can also be used as an index for row storage tables to provide intelligent OLAP services externally and improve the performance of complex mixed queries by about 10 times.

TiFlash is currently in Beta with GA scheduled before December 31, 2019. Please apply for a trial.

7. Future planning

In the future, we will continue to invest in system stability, ease of use, performance, elastic expansion, to provide users with the ultimate elastic expansion ability, the ultimate performance experience, the ultimate user experience.

In terms of stability, V4.0 will continue to improve the significant features of V3.0 without GA, such as: pessimistic transaction model, View, Table Partition, Titan row storage engine, TiFlash column storage engine; The approximate physical backup and recovery are introduced to solve the problem of distributed database backup and recovery. Optimize PD scheduling function, etc.

In terms of performance, V4.0 will continue to optimize the transaction process to reduce transaction resource consumption and improve performance, such as: 1PC, eliminating the need to obtain COMMIT TS operations.

In terms of elastic expansion, PD will provide meta information required by elastic expansion for external system to call, and the external system can dynamically scale the cluster according to the meta information and load to achieve the goal of cost saving.

8. Community Profile

We believe that the best weapon against the unknown is the power of the community, and that basic software needs to be firmly open source. As of this writing, we have completed 41 source reading articles. There are 265 contributors and 6 committers in the TiDB open source community. We would like to express our heartfelt thanks to the contributors and hope that more like-minded people can join us and enjoy TiDB as an open source community.

TiDB 3.0 GA Release Notes: pingcap.com/docs-cn/v3….