PI Elimination
Scenario
In the current partitioned table architecture, the executor iteratively accesses each partition by using the Partition Iterator (PI) operator. When the partition pruning result has only one partition, the PI operator has lost its function as an iterator. In this case, eliminating the PI operator can avoid some unnecessary overheads during execution. Due to the PIPELINE architecture of the executor, the PI operator is executed repeatedly. In scenarios with a large amount of data, the benefits of eliminating the PI operator are considerable.
Example
The PI elimination takes effect only after the GUC parameter partition_iterator_elimination is enabled. The following is an example:
gaussdb=# CREATE TABLE test_range_pt (a INT, b INT, c INT) PARTITION BY RANGE (a) ( PARTITION p1 VALUES LESS THAN (2000), PARTITION p2 VALUES LESS THAN (3000), PARTITION p3 VALUES LESS THAN (4000), PARTITION p4 VALUES LESS THAN (5000), PARTITION p5 VALUES LESS THAN (MAXVALUE) )ENABLE ROW MOVEMENT; gaussdb=# EXPLAIN SELECT * FROM test_range_pt WHERE a = 3000; QUERY PLAN ---------------------------------------------------------------------------------- Partition Iterator (cost=0.00..25.31 rows=10 width=12) Iterations: 1 -> Partitioned Seq Scan on test_range_pt (cost=0.00..25.31 rows=10 width=12) Filter: (a = 3000) Selected Partitions: 3 (5 rows) gaussdb=# SET partition_iterator_elimination = on; SET gaussdb=# EXPLAIN SELECT * FROM test_range_pt WHERE a = 3000; QUERY PLAN ---------------------------------------------------------------------------- Partitioned Seq Scan on test_range_pt (cost=0.00..25.31 rows=10 width=12) Filter: (a = 3000) Selected Partitions: 3 (3 rows) -- Cleanup example gaussdb=# DROP TABLE test_range_pt;
Precautions and Constraints
- The optimization in the target scenario takes effect only when the GUC parameter partition_iterator_elimination is enabled and the optimizer pruning result contains only one partition.
- The PI operator does not support level-2 partitioned tables.
- CPLAN and some GPLAN scenarios are supported, for example, the partition key a = $1 (that is, the scenario where data can be pruned to one partition in the optimizer phase).
- The SeqScan, Indexscan, Indexonlyscan, Bitmapscan, RowToVec, and Tidscan operators are supported.
- Row store, Astore, Ustore, and SQLBypass are supported.
- The PI operator can be eliminated only when its lower-layer operator is a supported Scan operator.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot