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 21:35:56
Message-ID: DJRT8HKM3HB1.S95AW0X2TUZK@jeltef.nl
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon Jul 6, 2026 at 7:16 PM CEST, Tom Lane wrote:
>> 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.
>
> Yeah, that was my immediate reaction to your message. I agree it's
> only material for HEAD, but here's a draft patch to do that.

I found two other edge cases worth considering for this. Which is why I
didn't pursue it further, because I assumed with those two existing
there were probably some more that I missed (and indeed I had missed
that regexes should always be lossy, and there might be more still):

1. bpchar columns should be lossy because LIKE and = behave differently
for padded values.
2. When the index has a collation, but no collation can be detected for
the expression, then we currently throw an error during the recheck.
It seems strange to me to throw that error during execution instead
of planning, but it seems even weirder that removing the recheck
would make the query succeed.

Attached a v2 draft patch that adds some tests for those cases and
checks to handle them (and some comments by an LLM that I haven't
cleaned up much). I think issue 2 might need a different approach
altogether.

To be clear, I don't plan to pursue this further right now, just wanted
to share the details of my investigation in case you want to take it
further.

Attachment Content-Type Size
v2-0001-Treat-exact-match-LIKE-pattern-as-non-lossy-in-ce.patch text/x-patch 16.2 KB

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Zsolt Parragi 2026-07-06 21:53:51 Re: Global temporary tables
Previous Message Jeff Davis 2026-07-06 21:33:00 Selectivity fix for like_fixed_prefix_ci()