Query acceleration

Updated at:

This topic describes the acceleration capabilities, performance, and observability methods of PolarDB for MySQL columnstore tables during the single-node execution phase. By default, the optimizer first determines whether a columnstore query uses a massively parallel processing (MPP) plan. After a query is dispatched to an execution node, the node still relies on single-node columnar execution optimizations to reduce latency. This topic focuses on these in-node execution optimization capabilities.

Background and value

As the data volume of analytical queries continues to grow, single-node execution can easily become a bottleneck in the following aspects:

  • Reading columns that the query does not need

  • Scanning data blocks that are ultimately filtered out

  • Repeatedly reading and decoding the same data pages

  • Single-node caches that cannot cover hot data

  • High CPU and memory bandwidth requirements for aggregation, joins, and sorting on large tables

The columnar execution acceleration capability of fully columnstore tables aims to apply the following principles throughout the execution pipeline: read only the required columns, process only the necessary data, and reuse decoded results wherever possible. This reduces query latency and improves throughput.

In the execution pipeline, these optimizations are mainly reflected in the following aspects:

  • Data is read only for the columns required by the query, which reduces unnecessary column scans.

  • Pushable predicates are pushed down to the underlying storage wherever possible, so that stripe-level or data block pruning is performed in advance.

  • Files are quickly filtered by using visibility views, which reduces the number of irrelevant rows that enter the subsequent aggregation, sorting, and expression computation stages.

  • The OSS page cache and the metadata cache are reused, which reduces the cost of repeated reads and repeated decoding.

  • Data is delivered to the execution layer in batches to take advantage of vectorized batch processing.

Relationship with multi-node parallel execution and how to determine the execution plan

This topic focuses on single-node execution acceleration. For information about the multi-node massively parallel processing capabilities, applicable scenarios, and partition design of columnstore tables, see Multi-node analysis.

To determine whether a specific SQL statement ultimately uses an MPP plan, check whether the Exchange operator exists in the execution plan.

EXPLAIN SELECT /*+ SET_VAR(imci_plan_use_mpp=forced) */ COUNT(*) FROM nation;

If the Exchange operator appears in the execution plan, the SQL statement can use the multi-node parallel execution capability of columnstore tables. If the Exchange operator appears in the actual execution plan, the SQL statement ultimately runs as an MPP plan. Conversely, if no Exchange operator is present in the execution plan, the SQL statement runs as a single-node plan.

Performance test results

The following are the single-node warm-cache test results of fully columnstore tables on an instance with 32 cores and 256 GB of memory, based on TPC-H 1 100 GB:

Note

The TPC-H implementation in this topic is based on TPC-H benchmarking. These test results cannot be compared with published TPC-H benchmark results because the tests do not fully meet all TPC-H requirements.

Query

Time(s)

Q1

1.175

Q2

0.178

Q3

0.577

Q4

0.433

Q5

0.522

Q6

0.366

Q7

0.633

Q8

0.528

Q9

2.817

Q10

0.935

Q11

0.218

Q12

0.535

Q13

1.255

Q14

0.442

Q15

0.889

Q16

0.553

Q17

0.738

Q18

2.381

Q19

0.759

Q20

0.453

Q21

1.308

Q22

0.299

TOTAL

17.994