Re: pg_stat_statements and "IN" conditions

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>
Cc: Sami Imseih <samimseih(at)gmail(dot)com>, Kirill Reshke <reshkekirill(at)gmail(dot)com>, Sergei Kornilov <sk(at)zsrv(dot)org>, yasuo(dot)honda(at)gmail(dot)com, tgl(at)sss(dot)pgh(dot)pa(dot)us, smithpb2250(at)gmail(dot)com, vignesh21(at)gmail(dot)com, michael(at)paquier(dot)xyz, nathandbossart(at)gmail(dot)com, stark(dot)cfm(at)gmail(dot)com, geidav(dot)pg(at)gmail(dot)com, marcos(at)f10(dot)com(dot)br, robertmhaas(at)gmail(dot)com, david(at)pgmasters(dot)net, pgsql-hackers(at)postgresql(dot)org, pavel(dot)trukhanov(at)gmail(dot)com, Sutou Kouhei <kou(at)clear-code(dot)com>
Subject: Re: pg_stat_statements and "IN" conditions
Date: 2025-02-13 16:50:09
Message-ID: z7daminuuasjjunvhul5q5zwvjjrkvkldizq6oriufxnjvq6l5@6tgsib66vp7c
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Thu, Feb 13, 2025 at 01:47:01PM GMT, Álvaro Herrera wrote:
> Also, how wed are you to
> "query_id_merge_values" as a name? It's not in any way obvious that
> this is about values in arrays. How about query_id_squash_arrays? Or
> are you thinking in having values in other types of structures squashed
> as well, and that this first patch does it for arrays only but you want
> the GUC to also control some future feature?
>
> (I think I prefer "squash" here as a verb to "merge").

Yeah, when choosing the name I was trying to keep it a bit generic. The
high level goal is to reduce repeated non-essential parts, and arrays of
constants are one clear scenario, but there could be more to it. Having
said that I don't have any particular plans for extending this logic so
far. I've ended up with query_id_squash_values, how does this sound?

> I think calling func_volatile potentially once per array element is not
> good; this might cause dozens/thousands of identical syscache lookups.
> Maybe we can pass an initially NIL list from IsMergeableConstList (as
> List **), which IsMergeableConst fills with OIDs of functions that have
> been checked and found acceptable. Then the second time around we
> search the list first and only do func_volatile() after not finding a
> match.

Good point, added.

> Another thing I didn't quite understand is why you did this rather
> baroque-looking list scan:

I'm pretty sure there was some reason behind it, but when you pointed it
out that reason has promptly vanished in a puff of confusion. Fixed.

Attachment Content-Type Size
v24-0001-Prevent-jumbling-of-every-element-in-ArrayExpr.patch text/plain 44.6 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Justin Pryzby 2025-02-13 16:51:27 pg17.3 PQescapeIdentifier() ignores len
Previous Message Sami Imseih 2025-02-13 16:44:33 Re: [PATCH] Optionally record Plan IDs to track plan changes for a query