postgresql/src/include
Alexander Korotkov c0962a113d Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate
This commit implements the automatic conversion of 'x IN (VALUES ...)' into
ScalarArrayOpExpr.  That simplifies the query tree, eliminating the appearance
of an unnecessary join.

Since VALUES describes a relational table, and the value of such a list is
a table row, the optimizer will likely face an underestimation problem due to
the inability to estimate cardinality through MCV statistics.  The cardinality
evaluation mechanism can work with the array inclusion check operation.
If the array is small enough (< 100 elements), it will perform a statistical
evaluation element by element.

We perform the transformation in the convert_ANY_sublink_to_join() if VALUES
RTE is proper and the transformation is convertible.  The conversion is only
possible for operations on scalar values, not rows.  Also, we currently
support the transformation only when it ends up with a constant array.
Otherwise, the evaluation of non-hashed SAOP might be slower than the
corresponding Hash Join with VALUES.

Discussion: https://postgr.es/m/0184212d-1248-4f1f-a42d-f5cb1c1976d2%40tantorlabs.com
Author: Alena Rybakina <a.rybakina@postgrespro.ru>
Author: Andrei Lepikhov <lepihov@gmail.com>
Reviewed-by: Ivan Kush <ivan.kush@tantorlabs.com>
Reviewed-by: Alexander Korotkov <aekorotkov@gmail.com>
2025-04-04 16:01:50 +03:00
..
access Remove HeapBitmapScan's skip_fetch optimization 2025-04-02 14:54:20 -04:00
archive Update copyright for 2025 2025-01-01 11:21:55 -05:00
backup Update copyright for 2025 2025-01-01 11:21:55 -05:00
bootstrap pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
catalog Extend ALTER DEFAULT PRIVILEGES to define default privileges for large objects. 2025-04-04 19:02:17 +09:00
commands Add an additional hook for EXPLAIN option validation. 2025-03-20 13:47:55 -04:00
common Update Unicode data to Unicode 16.0.0 2025-04-03 12:00:09 +02:00
datatype Avoid using timezone Asia/Manila in regression tests. 2025-01-20 15:47:53 -05:00
executor Change SQL-language functions to use the plan cache. 2025-04-02 14:06:02 -04:00
fe_utils pg_rewind: Add dbname to primary_conninfo when using --write-recovery-conf. 2025-03-12 16:56:04 -07:00
foreign Update copyright for 2025 2025-01-01 11:21:55 -05:00
jit Fix grammatical typos around possessive "its" 2025-01-29 14:39:14 +07:00
lib Use PRI?64 instead of "ll?" in format strings (continued). 2025-03-29 10:43:57 +01:00
libpq Make cancel request keys longer 2025-04-02 16:41:48 +03:00
mb pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
nodes Convert PathKey to use CompareType 2025-04-04 11:22:20 +02:00
optimizer Convert 'x IN (VALUES ...)' to 'x = ANY ...' then appropriate 2025-04-04 16:01:50 +03:00
parser Extend ALTER DEFAULT PRIVILEGES to define default privileges for large objects. 2025-04-04 19:02:17 +09:00
partitioning Fix incorrect #endif comment 2025-03-10 13:36:04 +13:00
pch Update copyright for 2025 2025-01-01 11:21:55 -05:00
port Use function attributes for SSE 4.2 even when targeting that extension 2025-04-01 12:01:58 +07:00
portability Update copyright for 2025 2025-01-01 11:21:55 -05:00
postmaster pg_noreturn to replace pg_attribute_noreturn() 2025-03-13 12:37:26 +01:00
regex Update copyright for 2025 2025-01-01 11:21:55 -05:00
replication Use standard die() signal handler in walreceiver 2025-04-04 12:38:32 +03:00
rewrite Eliminate code duplication in replace_rte_variables callbacks 2025-02-25 16:11:34 +09:00
snowball Update to latest Snowball sources. 2025-02-18 21:13:54 -05:00
statistics Stats: use schemaname/relname instead of regclass. 2025-03-25 11:16:06 -07:00
storage Make cancel request keys longer 2025-04-02 16:41:48 +03:00
tcop Improve error message when standby does accept connections. 2025-04-02 15:13:01 +09:00
tsearch Update copyright for 2025 2025-01-01 11:21:55 -05:00
utils Revert "Improve accounting for memory used by shared hash tables" 2025-04-04 04:43:50 +02:00
.gitignore Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
c.h Use workaround of __builtin_setjmp only on MINGW on MSVCRT 2025-04-01 16:24:59 -04:00
fmgr.h Avoid mixing designated and non-designated field initializers. 2025-03-27 11:06:30 -04:00
funcapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
getopt_long.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
Makefile Use <stdint.h> and <inttypes.h> for c.h integers. 2024-12-04 15:05:38 +13:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
miscadmin.h Make cancel request keys longer 2025-04-02 16:41:48 +03:00
pg_config.h.in Add missing declarations to pg_config.h.in 2025-04-03 13:57:27 +02:00
pg_config_manual.h Avoid invalidating all RelationSyncCache entries on publication rename. 2025-03-13 09:16:33 +05:30
pg_getopt.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pg_trace.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
pgstat.h pgstat: Allow checksum errors to be reported in critical sections 2025-03-30 16:12:04 -04:00
pgtar.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgtime.h Seek zone abbreviations in the IANA data before timezone_abbreviations. 2025-01-16 14:11:19 -05:00
port.h Add timingsafe_bcmp(), for constant-time memory comparison 2025-04-02 15:32:40 +03:00
postgres.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
postgres_ext.h libpq: Deprecate pg_int64. 2025-03-25 21:40:00 +13:00
postgres_fe.h IWYU widely useful pragmas 2025-01-15 18:57:53 +01:00
varatt.h Update copyright for 2025 2025-01-01 11:21:55 -05:00
windowapi.h Update copyright for 2025 2025-01-01 11:21:55 -05:00