PG11 - Multiple Key Range Partition
Rares Salcudean <rares.salcudean@takeofflabs.com>
From: Rares Salcudean <rares.salcudean@takeofflabs.com>
To: pgsql-bugs@lists.postgresql.org
Date: 2019-07-08T09:05:22Z
Lists: pgsql-bugs
Hello, Currently, I'm trying to define a table with a range partition of 3 keys Recent, Deleted and Played At. There are multiple partitions: 1. scores_2018 (recent - false, deleted - false, played_at in (2018-01-01 / 2019-01-01) 2. scores_2017 (recent - false, deleted - false, played_at in (2017-01-01 / 2018-01-01) 3. scores_recent (recent - *true*, deleted - false, played_at in (1990-01-01 / 2090-01-01) 4. scores_deleted (recent - false, deleted - *true*, played_at in (1990-01-01 / 2090-01-01) When inserting all works fine, but when doing a select statement it does not correctly query over the correct partition, It searches on all partitions. *explain select * from scores where played_at = '2018-03-01'* [image: Screenshot 2019-07-08 at 12.01.15.png] *explain select * from scores where recent = true and deleted = false and played_at = '2018-03-01'* [image: Screenshot 2019-07-08 at 12.01.55.png] When using the *recent *key the partition is selected correctly. However, when using the *deleted* key it does a full search. *explain select * from scores where deleted = true* [image: Screenshot 2019-07-08 at 12.03.19.png] *Note:* If I only create the table with only 2 partition keys *Recent* and *Played* *at*, all works as expected. The 3 key range partition is not supported, or is it a bug? Can you please suggest an alternative? The main idea is to have multiple partitions, one for each year and an extra 2, for deleted scores, and recent scores. Thank you and have a great day! Rares
Commits
-
Fix RANGE partition pruning with multiple boolean partition keys
- cfde23493938 13.0 landed
- 30a268ed2e29 12.0 landed
- 757f1baa8c13 11.5 landed