PG11 - Multiple Key Range Partition - Mailing list pgsql-bugs

From Rares Salcudean
Subject PG11 - Multiple Key Range Partition
Date
Msg-id CAHp_FN2xwEznH6oyS0hNTuUUZKp5PvegcVv=Co6nBXJ+mC7Y5w@mail.gmail.com
Whole thread Raw
Responses Re: PG11 - Multiple Key Range Partition  (David Rowley <david.rowley@2ndquadrant.com>)
List 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'

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'

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

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



Attachment

pgsql-bugs by date:

Previous
From: Prakash Ramakrishnan
Date:
Subject: perl issue
Next
From: Ádám Maracska
Date:
Subject: Re: PostgreSQL 11 can not restart after an unexpected shutdown