Re: Replace IN VALUES with ANY in WHERE clauses during optimization
Andres Freund <andres@anarazel.de>
From: Andres Freund <andres@anarazel.de>
To: Alexander Korotkov <aekorotkov@gmail.com>
Cc: Alena Rybakina <a.rybakina@postgrespro.ru>, Andrei Lepikhov <lepihov@gmail.com>, Ivan Kush <ivan.kush@tantorlabs.com>, pgsql-hackers <pgsql-hackers@postgresql.org>, Tom Lane <tgl@sss.pgh.pa.us>, Laurenz Albe <laurenz.albe@cybertec.at>
Date: 2025-04-04T14:39:53Z
Lists: pgsql-hackers
Commits
Same data as JSON:
GET /api/v1/messages/:b64id/commits
the thread's linked commits as JSON, with link sources.
API reference →
-
Stabilize regression test from c0962a113.
- 3ba2cdaa4541 18.0 landed
-
Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate
- c0962a113d1f 18.0 landed
-
Extract make_SAOP_expr() function from match_orclause_to_indexcol()
- d48d2e2dc8be 18.0 landed
On 2025-04-03 18:26:48 +0300, Alexander Korotkov wrote:
> On Thu, Apr 3, 2025 at 5:18 PM Alena Rybakina <a.rybakina@postgrespro.ru> wrote:
> > Okay, I agree with you.
>
> Good. I've reflected this limitation in comments and the commit
> message. Also, I've adjust regression tests by removing excessive
> ones and adding more important cases. I'm going to push this if no
> objections.
This just failed on both buildfarm and CI:
BF:
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=rhinoceros&dt=2025-04-04%2013%3A52%3A13
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=iguana&dt=2025-04-04%2014%3A08%3A50
https://buildfarm.postgresql.org/cgi-bin/show_log.pl?nm=rhinoceros&dt=2025-04-04%2013%3A52%3A13
...
CI:
https://cirrus-ci.com/task/5466958990147584
https://api.cirrus-ci.com/v1/artifact/task/5466958990147584/testrun/build/testrun/pg_upgrade/002_pg_upgrade/log/regress_log_002_pg_upgrade
--- C:/cirrus/src/test/regress/expected/subselect.out 2025-04-04 13:20:49.429815400 +0000
+++ C:/cirrus/build/testrun/pg_upgrade/002_pg_upgrade/data/results/subselect.out 2025-04-04 13:23:33.602847700 +0000
@@ -2769,15 +2769,16 @@
EXPLAIN (COSTS OFF)
SELECT c.oid,c.relname FROM pg_class c JOIN pg_am a USING (oid)
WHERE c.oid IN (VALUES (1), (2));
- QUERY PLAN
----------------------------------------------------------------
- Hash Join
- Hash Cond: (a.oid = c.oid)
- -> Seq Scan on pg_am a
- -> Hash
- -> Index Scan using pg_class_oid_index on pg_class c
- Index Cond: (oid = ANY ('{1,2}'::oid[]))
-(6 rows)
+ QUERY PLAN
+---------------------------------------------------------
+ Merge Join
+ Merge Cond: (c.oid = a.oid)
+ -> Index Scan using pg_class_oid_index on pg_class c
+ Index Cond: (oid = ANY ('{1,2}'::oid[]))
+ -> Sort
+ Sort Key: a.oid
+ -> Seq Scan on pg_am a
+(7 rows)
-- Constant expressions are simplified
EXPLAIN (COSTS OFF)
This failure was entirely predictable, as this patch has been failing on cfbot
for *months*. Seriously. The tests passed exactly once since 2024-11-26, see:
https://cirrus-ci.com/github/postgresql-cfbot/postgresql/cf%2F5283
Come-on.