Re: Make \d tablename fast again, regression introduced by 85b7efa1cdd

From: "Jelte Fennema-Nio" <postgres(at)jeltef(dot)nl>
To: "Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: "Andres Freund" <andres(at)anarazel(dot)de>, "PostgreSQL-development" <pgsql-hackers(at)postgresql(dot)org>, "Dilip Kumar" <dilipbalaut(at)gmail(dot)com>, "Thomas Munro" <thomas(dot)munro(at)gmail(dot)com>, "Noah Misch" <noah(at)leadboat(dot)com>, "Peter Eisentraut" <peter(at)eisentraut(dot)org>
Subject: Re: Make \d tablename fast again, regression introduced by 85b7efa1cdd
Date: 2026-07-06 11:21:30
Message-ID: DJRG61N6ISDV.13P5KBP27CNQ0@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Sat, 4 Jul 2026 at 22:27, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> I looked this over, and I think it's basically right, but don't
> we need to check that *both* of the collations are deterministic?

That's not what the code did before 85b7efa1c at least. And I think that's
correct because I think it's fine if the index collation is
nondeterministic: it'll return a superset of the matches that the
expression collation thinks are equal, and then the recheck condition will
filter out the conflicting cases (because it's marked as lossy).

Attached is v3, which adds a test for this case and expands the comment. I
left your commit message improvements as is, I agree that the message is a
lot better after your changes (I was indeed sorely mistaken about the
general prefix pattern optimization being impacted, the regex addition
is nice but seems relatively minor).

P.S. I think we could mark the comparisons in certain cases as
non-lossy, but after trying that for a bit the details turn out more
complicated than I expected. And that's definitely not something to backport.

Attachment Content-Type Size
v3-0001-Fix-LIKE-regex-optimization-for-indexscan-with-ex.patch text/x-patch 9.1 KB

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Dave Cramer 2026-07-06 11:26:37 Scrollable cursors at the protocol level
Previous Message Heikki Linnakangas 2026-07-06 11:04:08 Re: Implement waiting for wal lsn replay: reloaded