Re: pg_stat_statements and "IN" conditions

From: Dmitry Dolgov <9erthalion6(at)gmail(dot)com>
To: Sami Imseih <samimseih(at)gmail(dot)com>
Cc: Julien Rouhaud <rjuju123(at)gmail(dot)com>, Álvaro Herrera <alvherre(at)alvh(dot)no-ip(dot)org>, 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-17 17:16:30
Message-ID: i3ts47ewsvg4adcx4mywebgvuz6ubvir56fmhuuvuy4fjb2gsa@d2vo3oz46zd3
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

> On Mon, Feb 17, 2025 at 09:51:32AM GMT, Sami Imseih wrote:
> > This should do it. The last patch for today,
>
> I looked at v27 today and have a few comments.
>
> 1/ It looks like the CTE test is missing a check for results.

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.

> 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?

> 3/ Here, this looks wrong as we could end up traversing an elements list
> twice. Once inside IsMergeableConstList and if that call returns false, we end
> up traversing through the elements list again in _jumbleNode.

IsMergeableConstList and _jumbleNode serve different purposes, so it's
probably unwise to try to replace one with another. E.g.
IsMergeableConstList will stop at the first non-constant expression, so
it's not a full traversal.

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Andres Freund 2025-02-17 17:24:46 Re: Bump soft open file limit (RLIMIT_NOFILE) to hard limit on startup
Previous Message Andres Freund 2025-02-17 16:59:17 Re: Add pg_buffercache_evict_all() and pg_buffercache_mark_dirty[_all]() functions