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

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: "Jelte Fennema-Nio" <postgres@jeltef.nl>
Cc: "Andres Freund" <andres@anarazel.de>, "PostgreSQL-development" <pgsql-hackers@postgresql.org>, "Dilip Kumar" <dilipbalaut@gmail.com>, "Thomas Munro" <thomas.munro@gmail.com>, "Noah Misch" <noah@leadboat.com>, "Peter Eisentraut" <peter@eisentraut.org>
Date: 2026-07-04T20:27:05Z
Lists: pgsql-hackers

Attachments

"Jelte Fennema-Nio" <postgres@jeltef.nl> writes:
> (forked from: Test timings are increasing too fast for cfbot)
> On Wed, 25 Mar 2026 at 04:15, Andres Freund <andres@anarazel.de> wrote:
>> It seems decidedly not optimal that "\d tablename", without any patterns, ends
>> up doing a seqscan.
>> ...
>> I don't think this was always the case?

> Due to a very similar problem I faced in the past[1], I thought I had a
> good sense of where roughly the problem was. And I indeed quickly found
> it.
> Attached is a patch that addresses this issue and starts using index
> scans again for \d tablename.

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?

Also the commit message had a lot of details wrong.  AFAICS this
only affects the exact-match case not prefix-match, and it applies
to regexes as well as LIKE.

See attached v2.

			regards, tom lane