psql: Greatly speed up "\d tablename" when not using regexes

From: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
To: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: psql: Greatly speed up "\d tablename" when not using regexes
Date: 2024-04-10 15:50:42
Message-ID: CAGECzQRqysy0eJMKR5he3gwtLrT87f9u5CQQua6B_XNwMnUtFA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Running "\d tablename" from psql could take multiple seconds when
running on a system with 100k+ tables. The reason for this was that
a sequence scan on pg_class takes place, due to regex matching being
used.

Regex matching is obviously unnecessary when we're looking for an exact
match. This checks for this (common) case and starts using plain
equality in that case.

Attachment Content-Type Size
v1-0001-psql-Greatly-speed-up-d-tablename-when-not-using-.patch application/octet-stream 3.6 KB

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Robert Haas 2024-04-10 15:54:22 Re: Issue with the PRNG used by Postgres
Previous Message Tom Lane 2024-04-10 15:33:37 Re: Speed up clean meson builds by ~25%