Re: Query ID Calculation Fix for DISTINCT / ORDER BY and LIMIT / OFFSET

From: David Rowley <dgrowleyml(at)gmail(dot)com>
To: Michael Paquier <michael(at)paquier(dot)xyz>
Cc: Bykov Ivan <i(dot)bykov(at)modernsys(dot)ru>, Sami Imseih <samimseih(at)gmail(dot)com>, "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Query ID Calculation Fix for DISTINCT / ORDER BY and LIMIT / OFFSET
Date: 2025-03-26 23:09:35
Message-ID: CAApHDvr+gY9xvb+48PW06wCROqFiP47tnnDmZTZh1Kf6cO0uCg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Wed, 26 Mar 2025 at 14:04, Michael Paquier <michael(at)paquier(dot)xyz> wrote:
>
> On Wed, Mar 26, 2025 at 11:56:50AM +1300, David Rowley wrote:
> > Here is the v8 version with the bug fix and performance stuff
> > separated out.
>
> Why not. I assume that you would merge these together?

I think it's better it's two commits. They're for different purposes.

> I disagree about the lack of tests. These are cheap to add. I'd
> suggest to not use the ones posted as part of v2 variant B as these do
> not require the creation of a relation so they can be made cheaper,
> and instead use the set I have posted in patch 0001 here which covers
> most of the main scenarios from the parser with this nodes in the
> Query:
> https://www.postgresql.org/message-id/Z9z85Ui5lPkPn2hq@paquier.xyz

Ok, I won't protest. I just feel the bug is a relic of the old design
and I don't believe the tests are testing anything useful in the new
design. It feels unlikely that someone accidentally adjusts the code
and reverts it to the old design. Anyway, I've included the tests from
your patch.

> It is a bit disappointing that we require JumbleQuery() to jumble the
> NULLs. There are discussions about making this code available not
> only for Querys, but for Nodes, and the NUL computations would be
> missed..

I've adjusted the patch to add two static functions. InitJumble() and
DoJumble(). JumbleQuery() uses these.

David

Attachment Content-Type Size
v9-0001-Fix-query-jumbling-to-account-for-NULL-nodes.patch application/octet-stream 11.2 KB
v9-0002-Optimize-Query-jumble.patch application/octet-stream 6.3 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Jianghua Yang 2025-03-26 23:54:12 Re: Use CLOCK_MONOTONIC_COARSE for instr_time when available
Previous Message Michael Paquier 2025-03-26 23:09:12 Re: Doc: clarify possibility of ephemeral discrepancies between state and wait_event in pg_stat_activity