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-12 18:14:52 |
Message-ID: | fou2if7f5m7phpj27h7whn62vz4dsbbevj6xuglvl7dle2uwft@bz3g4yfzddks |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
> On Tue, Feb 11, 2025 at 08:00:27PM GMT, Dmitry Dolgov wrote:
> > Hmm, what about doing something much simpler, such as testing whether
> > there's just a CoerceViaIO/RelabelType around a Const or a one-parameter
> > function call of an immutable boostrap-OID function that has a Const as
> > argument, and trivial cases like that? Something very very simple
> > that's going to catch the majority of cases without anything as complex
> > as a node walker.
> >
> > Maybe something like statext_is_compatible_clause_internal() can be an
> > inspiration (and even that is far more complex than we need here.)
>
> I'm somewhat hesitant to cover only some cases, but let me try, maybe
> it's indeed going to be good enough.
I've been experimenting with this today, and while it's easy to
implement, there is one annoying thing for which I don't have a solution
yet. When generating a normalized version for such merged queries in
pgss we rely on expression location, something like:
select i from t where i in (a1, a2, a3, ..., aN);
| |
expr loc1 expr loc2
We remember loc1 and loc2, then do not copy anything between then into
the normalized query. Now, the expression location is only known up to
the parsing token, without taking into account e.g. parenthesis in more
complex expressions. Which means we don't know exactly where an
expression starts or ends, and it's hard to correctly represent queries
like:
select i from t where i in (((a1)), ((a2)), ((a3)), ..., ((aN)));
| |
expr loc1 expr loc2
The normalized version looks like this:
select i from t where i in (((...)));
While it does not affect the actual functionality and is purely
cosmetic, it's quite visible and causes questions. In theory this could
be addressed by extending fill_in_constant_lengths to chase parenthesis,
but it sounds complicated. Another option is to try a different visual
representation of merging, something that will keep the first and the
last constant intact.
From | Date | Subject | |
---|---|---|---|
Next Message | Yura Sokolov | 2025-02-12 18:16:12 | Re: Get rid of WALBufMappingLock |
Previous Message | Robert Haas | 2025-02-12 18:11:07 | Re: explain analyze rows=%.0f |