Re: Replace IN VALUES with ANY in WHERE clauses during optimization

From: Alena Rybakina <a(dot)rybakina(at)postgrespro(dot)ru>
To: Alexander Korotkov <aekorotkov(at)gmail(dot)com>
Cc: Andrei Lepikhov <lepihov(at)gmail(dot)com>, Ivan Kush <ivan(dot)kush(at)tantorlabs(dot)com>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
Subject: Re: Replace IN VALUES with ANY in WHERE clauses during optimization
Date: 2025-02-20 21:09:27
Message-ID: d6809313-c0ca-4338-88e5-e8bc424bdfda@postgrespro.ru
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi!

On 09.02.2025 18:38, Alexander Korotkov wrote:
>> Also, aren't we too restrictive while requiring is_simple_values_sequence()?
>> For instance, I believe cases like this (containing Var) could be transformed too.
>>
>> select * from t t1, lateral (select * from t t2 where t2.i in (values (t1.i), (1)));
I'm still working on it.
> Also, I think there is quite a code duplication about construction of
> SAOP between match_orclause_to_indexcol() and convert_VALUES_to_ANY()
> functions. I would like to see a refactoring as a separate first
> patch, which extracts the common part into a function.

Done.

I have attached a patch. In addition to the transfer, I added the
process of searching for a suitable operator and type for the left
expression for input expressions: const and left expression, since they
may differ from the declared types. Additionally, we convert the left
expr to a type suitable for the found operator.

--
Regards,
Alena Rybakina
Postgres Professional

Attachment Content-Type Size
v3-0002-Add-an-implementation-of-the-x-IN-VALUES-to-x-ANY-.-.patch text/x-patch 30.9 KB
v3-0001-Move-the-function-for-generating-ArrayExpr-to-anothe.patch text/x-patch 9.7 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Noah Misch 2025-02-20 22:07:54 Re: pg_trgm comparison bug on cross-architecture replication due to different char implementation
Previous Message Markus Wanner 2025-02-20 20:49:46 Reset the output buffer after sending from WalSndWriteData