Re: BUG #17885: slow planning constraint_exclusion

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: sk(at)zsrv(dot)org, pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: BUG #17885: slow planning constraint_exclusion
Date: 2023-04-04 22:53:58
Message-ID: CAApHDvrsvM-6p07je7rM0xE+iMXdvCWUXJKBrNgL-JyoF0cePQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

On Wed, 5 Apr 2023 at 10:16, David Rowley <dgrowleyml(at)gmail(dot)com> wrote:
> We still run relation_excluded_by_constraints() after partition
> pruning only the remaining partitions. I believe there were some
> cases that we still didn't prune that relation_excluded_by_constraints
> was able to eliminate. I don' recall the exact details of what those
> cases are. I believe the call to relation_excluded_by_constraints()
> was kept due to this.

I may have misremembered that. On digging further, it seems we don't
run relation_excluded_by_constraints() using the partition constraint.
That's fairly evident by looking at the code and also noticing that we
don't prune partitions with partition_pruning=off.

The extra time is being spent checking the base quals don't refute
each other. That's able to determine that something like the
following can't return anything:

postgres=# explain select * from part_test where col_a = col_b and
col_a <> col_b;
QUERY PLAN
------------------------------------------
Result (cost=0.00..0.00 rows=0 width=0)
One-Time Filter: false
(2 rows)

Same recommendation as before - if you don't want it, just turn it off.

David

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Maxim Boguk 2023-04-05 00:30:17 Re: BUG #17885: slow planning constraint_exclusion
Previous Message David Rowley 2023-04-04 22:16:28 Re: BUG #17885: slow planning constraint_exclusion