Re: pg_stat_statements and "IN" conditions
Sami Imseih <samimseih@gmail.com>
From: Sami Imseih <samimseih@gmail.com>
To: Dmitry Dolgov <9erthalion6@gmail.com>
Cc: Julien Rouhaud <rjuju123@gmail.com>, Álvaro Herrera <alvherre@alvh.no-ip.org>, Kirill Reshke <reshkekirill@gmail.com>, Sergei Kornilov <sk@zsrv.org>, yasuo.honda@gmail.com, tgl@sss.pgh.pa.us, smithpb2250@gmail.com, vignesh21@gmail.com, michael@paquier.xyz, nathandbossart@gmail.com, stark.cfm@gmail.com, geidav.pg@gmail.com, marcos@f10.com.br, robertmhaas@gmail.com, david@pgmasters.net, pgsql-hackers@postgresql.org, pavel.trukhanov@gmail.com, Sutou Kouhei <kou@clear-code.com>
Date: 2025-02-17T19:50:00Z
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 →
-
Introduce squashing of constant lists in query jumbling
- 62d712ecfd94 18.0 landed
-
Make documentation builds reproducible
- b0f0a9432d0b 17.0 cited
-
Include values of A_Const nodes in query jumbling
- 9ba37b2cb6a1 16.0 cited
-
Teach planner about more monotonic window functions
- 456fa635a909 16.0 cited
-
Split up guc.c for better build speed and ease of maintenance.
- 0a20ff54f5e6 16.0 cited
Attachments
- 0001-experiement-on-top-of-v27.patch (application/octet-stream) patch v27-0001
> This test was to catch a crash that was happening in older version of
> the patch, so it doesn't have to verify the actual pgss entry.
It seems odd to keep this test because of crash behavior experienced
in a previous version of the patch. if the crash reason was understood
and resolved, why keep it?
> > 2/ Looking at IsMergeableConst, I am not sure why we care about
> > things like function volatility, implicit cast or funcid > FirstGenbkiObjectId?
>
> Function volatility is important to establish how constant is the
> result, for now we would like to exclude not immutable functions. The
> implicit cast and builtin check are there to limit squashing and exclude
> explicit or user-created functions (the second is probably an overkill,
> but this could be gradually relatex later). Or are you not sure about
> something different?
My thoughts are when dealing with FuncExpr, if the first arg in the list of
func->args is a Const, shouldn't that be enough to tell us that we have
a mergeable value. If it's not a Const, it may be another FuncExpr, so
that tells us we don't have a mergeable list. Why would this not be enough?
See the attached 0001-experiement-on-top-of-v27.patch
which applies on top of v27 and produces the results like below.
postgres=# explain verbose select from test_merge where id in (1, 2,
3, 4, 5, 6::bigint);
QUERY PLAN
-------------------------------------------------------------------
Seq Scan on public.test_merge (cost=0.00..49.55 rows=68 width=0)
Filter: (test_merge.id = ANY ('{1,2,3,4,5,6}'::bigint[]))
Query Identifier: 9190277587190463639
(3 rows)
postgres=# explain verbose select from test_merge where id in (1, 2,
3, 4, 5, 6::bigint, 7);
QUERY PLAN
-------------------------------------------------------------------
Seq Scan on public.test_merge (cost=0.00..52.38 rows=79 width=0)
Filter: (test_merge.id = ANY ('{1,2,3,4,5,6,7}'::bigint[]))
Query Identifier: 9190277587190463639
(3 rows)
postgres=# explain verbose select from test_merge where id in (1, 2,
3, 4, 5, 6::bigint, 7, testf5(1));
QUERY PLAN
---------------------------------------------------------------------------------------------------------------------------------------------------------
Seq Scan on public.test_merge (cost=0.00..625.85 rows=90 width=0)
Filter: (test_merge.id = ANY (ARRAY['1'::bigint, '2'::bigint,
'3'::bigint, '4'::bigint, '5'::bigint, '6'::bigint, '7'::bigint,
(testf5(1))::bigint]))
Query Identifier: 4874022288496461916
(3 rows)
--
Sami