From: | David Rowley <dgrowleyml(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | william(dot)duclot(at)gmail(dot)com, PostgreSQL mailing lists <pgsql-bugs(at)lists(dot)postgresql(dot)org> |
Subject: | Re: BUG #17540: Prepared statement: PG switches to a generic query plan which is consistently much slower |
Date: | 2023-07-05 23:55:36 |
Message-ID: | CAApHDvqHCNKJi9CrQZG-reQDXTfRWnT5rhzNtDQhnrBzAAusfA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs pgsql-hackers |
On Thu, 7 Jul 2022 at 15:50, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>
> David Rowley <dgrowleyml(at)gmail(dot)com> writes:
> > Anyway, I've no current plans to take the attached any further. I
> > think it'll be better to pursue your NULLable-Var stuff and see if we
> > can do something more generic like remove provably redundant NullTests
> > from baserestrictinfo.
>
> Yeah, I suspect that the way forward is to allow
> preprocess_minmax_aggregates to do what it does now, and then
> remove the IS NOT NULL clause again later when we have the
> info available to let us do that in a generic way.
I started looking at a more generic way to fix this. In the attached
I'm catching quals being added to baserestrictinfo in
distribute_restrictinfo_to_rels() and checking for IS NOT NULL quals
on columns defined with NOT NULL.
I did this by adding a new function add_baserestrictinfo_to_rel()
which can be the place where we add any future logic to ignore other
always-true quals. Perhaps in the future, we can add some logic there
to look for quals on partitions which are always true based on the
partition constraint.
I also took the opportunity here to slightly modernised the Bitmapset
code in this area. We previously called bms_membership() and then
bms_singleton_member(), which is not quite optimal. We invented
bms_get_singleton_member() as a more efficient way of getting that.
The empty set case can just be handled more easily now since you
changed empty sets to always be NULL. If it's not an empty set and not
a singleton, then it must contain multiple members.
I'm quite keen to see some forward progress on improving things for
this bug report. It would be good to take some more measures to stop
the planner being tricked into making silly mistakes. This is one
example of somewhere we could do better.
David
Attachment | Content-Type | Size |
---|---|---|
ignore_is_not_null_base_quals_on_not_null_columns.patch | text/plain | 5.7 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | 蔡梦娟 (玊于) | 2023-07-06 02:02:15 | The same 2PC data maybe recovered twice |
Previous Message | Tristan Partin | 2023-07-05 20:55:30 | Re: BUG #17946: LC_MONETARY & DO LANGUAGE plperl - BUG |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2023-07-06 00:19:11 | Re: pg_upgrade and cross-library upgrades |
Previous Message | Michael Paquier | 2023-07-05 23:34:00 | Re: Consider \v to the list of whitespace characters in the parser |