BitmapOr node not used in plan for ANY/IN but is for sequence of ORs ...

From: Jim Vanns <jvanns(at)ilm(dot)com>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: BitmapOr node not used in plan for ANY/IN but is for sequence of ORs ...
Date: 2024-11-13 12:08:40
Message-ID: CAH7vdhPq5GouBaNB-xb98Src7vQzzJbnw-XF52JeFLd7KZPd-w@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

(sent to general users mailing list yesterday - but perhaps this is a more
suitable audience?)

In PG16.4, we have a table of key/pair data (around 30M rows) where there
are about 7 distinct keys and each has a conditional or partial index on
them (the distribution is different for each key/value pair combination).
I've found that when we have a query that uses an OR then those partial
indexes are used but not if the query is written to use ANY/IN, which is
more convenient from a programmer POV (especially any with 3rd party query
generators etc.). Naturally, the result sets returned by the queries are
identical due to the filter semantics of any of the 3 solution variants.

Here's a shareable, MRP;

https://dbfiddle.uk/OKs_7HWv

Is there any trick I can do to get the planner to make use of the
conditional/partial index? Or is this simply an unoptimised code path yet
to be exploited!?

Cheers,

Jim

--
Jim Vanns
Principal Production Engineer
Industrial Light & Magic, London

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message torikoshia 2024-11-13 12:47:21 Re: Add reject_limit option to file_fdw
Previous Message Tomas Vondra 2024-11-13 11:55:01 Re: logical replication: restart_lsn can go backwards (and more), seems broken since 9.4