RE: Problem with default partition pruning
Yuzuko Hosoya <hosoya.yuzuko@lab.ntt.co.jp>
From: "Yuzuko Hosoya" <hosoya.yuzuko@lab.ntt.co.jp>
To: "'Amit Langote'" <Langote_Amit_f8@lab.ntt.co.jp>,
"'Thibaut'" <thibaut.madelaine@dalibo.com>,
"'Imai, Yoshikazu'" <imai.yoshikazu@jp.fujitsu.com>
Cc: "'PostgreSQL Hackers'" <pgsql-hackers@lists.postgresql.org>
Date: 2019-04-04T04:00:55Z
Lists: pgsql-hackers
Attachments
- v2_ignore_contradictory_where_clauses_at_partprune_step.patch (application/octet-stream) patch v2
- v4_default_partition_pruning.patch (application/octet-stream) patch v4
Amit-san,
Thanks for the comments.
>
> Thanks for dividing patches that way.
>
> Would it be a good idea to add some new test cases to these patches, just so it's easily apparent what
> we're changing?
Yes, I agree with you.
>
> So, we could add the test case presented by Thibaut at the following link to the
> default_partition_pruning.patch:
>
> https://www.postgresql.org/message-id/a4968068-6401-7a9c-8bd4-6a3bc9164a86%40dalibo.com
>
> And, another reported at the following link to
> ignore_contradictory_where_clauses_at_partprune_step.patch:
>
> https://www.postgresql.org/message-id/bd03f475-30d4-c4d0-3d7f-d2fbde755971%40dalibo.com
>
> Actually, it might be possible/better to construct the test queries in partition_prune.sql using the
> existing tables in that script, that is, without defining new tables just for adding the new test cases.
> If not, maybe it's OK to create the new tables too.
>
I see. I added some test cases to each patch according to tests
discussed in this thread.
However, I found another problem as follows. This query should
output "One-Time Filter: false" because rlp3's constraints
contradict WHERE clause.
-----
postgres=# \d+ rlp3
Partitioned table "public.rlp3"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
--------+-------------------+-----------+----------+---------+----------+--------------+-------------
b | character varying | | | | extended | |
a | integer | | | | plain | |
Partition of: rlp FOR VALUES FROM (15) TO (20)
Partition constraint: ((a IS NOT NULL) AND (a >= 15) AND (a < 20))
Partition key: LIST (b varchar_ops)
Partitions: rlp3abcd FOR VALUES IN ('ab', 'cd'),
rlp3efgh FOR VALUES IN ('ef', 'gh'),
rlp3nullxy FOR VALUES IN (NULL, 'xy'),
rlp3_default DEFAULT
postgres=# explain select * from rlp3 where a = 2;
QUERY PLAN
--------------------------------------------------------------------
Append (cost=0.00..103.62 rows=24 width=36)
-> Seq Scan on rlp3abcd (cost=0.00..25.88 rows=6 width=36)
Filter: (a = 2)
-> Seq Scan on rlp3efgh (cost=0.00..25.88 rows=6 width=36)
Filter: (a = 2)
-> Seq Scan on rlp3nullxy (cost=0.00..25.88 rows=6 width=36)
Filter: (a = 2)
-> Seq Scan on rlp3_default (cost=0.00..25.88 rows=6 width=36)
Filter: (a = 2)
(9 rows)
-----
I think that the place of check contradiction process was wrong
At ignore_contradictory_where_clauses_at_partprune_step.patch.
So I fixed it.
Attached the latest patches. Please check it again.
Best regards,
Yuzuko Hosoya
Commits
-
Don't constraint-exclude partitioned tables as much
- 815ef2f568c7 13.0 landed
-
Apply constraint exclusion more generally in partitioning
- 4e85642d935e 13.0 landed
-
Improve pruning of a default partition
- e3967a16d3a0 11.5 landed
- 86544071484a 12.0 landed
- 489247b0e615 13.0 landed
-
Doc: Fix event trigger firing table
- 44460d7017cd 13.0 cited
-
Remove obsolete nbtree insertion comment.
- 489e431ba56b 12.0 cited