From: | postgresql_contributors <postgresql_contributors(at)newtglobalcorp(dot)com> |
---|---|
To: | "ivan(dot)kush(at)tantorlabs(dot)com" <ivan(dot)kush(at)tantorlabs(dot)com> |
Cc: | Hari Prasad B <hariprsadb(at)newtglobalcorp(dot)com>, Kiran Suresh Kulkarni <kirans(at)newtglobalcorp(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org> |
Subject: | RE: Replace IN VALUES with ANY in WHERE clauses during optimization |
Date: | 2024-12-11 06:54:28 |
Message-ID: | TYZPR03MB81688A9CDB13B75660B616E4E13E2@TYZPR03MB8168.apcprd03.prod.outlook.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Hi Ivan,
I tested the patch using the input provided in commands.sql and observed improvements in both planning and execution time. These optimizations are especially noticeable when working with a mulitple tables. Even when querying just a single table, there is a small improvement in planning and execution time, with differences ranging from 0.02 to 0.04 ms.
CREATE TABLE test_table (
_id SERIAL PRIMARY KEY,
_val TEXT NOT NULL
);
INSERT INTO test_table (_val) VALUES
('a'),
('b'),
('c'),
('d'),
('e');
EXPLAIN ANALYZE
SELECT *
FROM test_table
WHERE _val IN ('b', 'd', 'e');
EXPLAIN ANALYZE
SELECT *
FROM test_table
WHERE _val IN (VALUES ('b'), ('d'), ('e'));
The patch optimizes IN clauses effectively, especially when the syntax uses VALUES.
When writing queries like:
col IN (VALUES ('a'), ('b'), ('c'))
the optimization makes it behave similarly to:
col IN ('a', 'b', 'c')
This leads to faster query execution times and reduced planning overhead.
Best Regards,
PostgreSQL Contributiors - Newt Global
[cid:55b37106-ab02-4cf9-b703-3cf4294d4600]
Newt Global India Pvt. Ltd.
SSPDL Alpha City , Gamma Block,
25, Rajiv Gandhi Salai (OMR),
Navalur, Chennai - 600130 .
From | Date | Subject | |
---|---|---|---|
Next Message | Bertrand Drouvot | 2024-12-11 07:00:50 | Re: Track the amount of time waiting due to cost_delay |
Previous Message | vignesh C | 2024-12-11 06:51:11 | Re: Introduce XID age and inactive timeout based replication slot invalidation |