v.21.4New Features
Add _partition_id Virtual Column and partitionID() Function for MergeTree Engines
Add_partition_idvirtual column forMergeTree*engines. Allow to prune partitions by_partition_id. AddpartitionID()function to calculate partition id string. #21401 (Amos Bird).
Why it matters
This feature allows users to efficiently filter and prune data partitions by using the_partition_id virtual column in queries. It improves query performance when working with partitioned tables by enabling direct access to partition identifiers. The partitionID() function provides a way to programmatically obtain the partition ID string for specific rows or data.How to use it
Users can use the_partition_id virtual column directly in the WHERE clause to filter partitions in SELECT, ALTER, and other queries on MergeTree* tables. The partitionID() function can be called in queries to get the partition ID string for a row. Example usage:SELECT * FROM table WHERE _partition_id = '2023-06-01';
SELECT partitionID() FROM table LIMIT 1;