When a query that involves a large amount of data is being executed, large amounts of compute resources are consumed as the SQL layer reads data from the storage engine layer and performs computation. To improve query performance, PolarDB for MySQL provides the fast traverse feature that pushes the optimizer down to the storage engine layer. This topic describes the fast traverse feature.
Prerequisites
- 8.0.1.1.5 or later
- 8.0.2.2.0 or later
For information about how to view the version of your cluster, see Query the engine version.
Background
In MySQL Community Edition 8.0.13, COUNT (*)
operations are not executed by the InnoDB engine, which causes heavy performance
overheads. In MySQL Community Edition 8.0.18, the records on an InnoDB page can be
traversed, but not according to the index selected by the optimizer. The primary key
index is used instead.
PolarDB for MySQL provides the fast traverse feature that allows the records on a page to be traversed based on the index selected by the optimizer. This feature prevents prolonged page lock hold caused by indexes that obtain data from tables and version restoration by Multiversion Concurrency Control (MVCC).
Use the fast traverse feature
The fast traverse feature is provided out-of-the box with supported PolarDB for MySQL clusters.
Performance test
mysql> EXPLAIN SELECT COUNT(*) FROM lineitem\G
*************************** 1. row ***************************
id: 1
select_type: SIMPLE
table: lineitem
partitions: NULL
type: index
possible_keys: NULL
key: i_l_shipdate
key_len: 4
ref: NULL
rows: 59440464
filtered: 100.00
Extra: Using index
Test results
innodb_parallel_read_threads
parameter is set to 1.