Re: WAIT FOR command should do some query jumbling

From: sirisha chamarthi <sirichamarthi22(at)gmail(dot)com>
To: Sami Imseih <samimseih(dot)pg(at)gmail(dot)com>
Cc: Peter Eisentraut <peter(at)eisentraut(dot)org>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org>, Alexander Korotkov <akorotkov(at)postgresql(dot)org>, Michael Paquier <michael(at)paquier(dot)xyz>
Subject: Re: WAIT FOR command should do some query jumbling
Date: 2026-08-30 21:34:14
Message-ID: CAKrAKeW81MwaEecB5r=we6fChZyjkTboynO+Tq-ajKXLntFv9g@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi Sami

On Sat, Aug 29, 2026 at 6:03 PM Sami Imseih <samimseih(dot)pg(at)gmail(dot)com> wrote:

> Hi,
>
> > The query jumbling facilities should be used to handle this.
>
> +1 for this. I think we need to do a bit more than what is suggested
> in v1-0001, which only normalizes the target LSN. I think we should
> also look at the rest of the rest of the WAIT FOR syntax and normalize
> option values, for example
>
> ```
> WAIT FOR LSN 'FFFFFFFF/FFFFFFFF'
> WITH (MODE 'primary_flush', TIMEOUT '1ms', NO_THROW);
>
> WAIT FOR LSN 'FFFFFFFE/FFFFFFFF'
> WITH (MODE 'primary_flush', TIMEOUT '2ms', NO_THROW);
> ```
>
> These should normalize to one pg_stat_statements entry
>
> ```
> WAIT FOR LSN $1 WITH (MODE $2, TIMEOUT $3, NO_THROW)
> ```
>
> Because these options are carried as DefElem, I think we should also
> track DefElem arg_location, and then statement parse nodes with such
> DefElem option lists can use pg_node_attr(custom_query_jumble) to
> traverse those lists and normalize the option values.
>
> WAIT FOR is one case, but I think the same approach could also be
> useful for other utility statements such as VACUUM and ALTER ROLE. For
> example, ALTER ROLE could normalize PASSWORD and VALID UNTIL. I have
> kept this series focused on WAIT FOR for now, though.
>
> So, attached in v2, v2-0001 adds the DefElem arg_location tracking,
> and v2-0002 adds the WAIT FOR jumbling changes.
> JumbleDefElemOptions() is a small helper in queryjumblefuncs.c that
> other statements can use to implement the same kind of option
> jumbling.
>
> CC'ing Michael also to get his thoughts on the approach.
>

Thanks Sami for the v2 patch! This patch applied cleanly and the tests
passed.
One observation with this approach is at times option can have different
meanings
and that may be lost during jumbling. For example, in the WAL FOR LSN case,
4 different MODEs are defined with different semantics and this patch does
not differentiate.

WAIT FOR LSN $1 WITH (MODE $2, TIMEOUT $3, NO_THROW)

Regards,
Sirisha

>

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Sami Imseih 2026-08-30 22:27:59 Re: WAIT FOR command should do some query jumbling
Previous Message Andrew Dunstan 2026-08-30 21:24:52 Re: Allow tuple visibility checks without hint-bit, maintenance