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

From: Kirill Reshke <reshkekirill(at)gmail(dot)com>
To: Jelte Fennema-Nio <postgres(at)jeltef(dot)nl>
Cc: PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: psql: Greatly speed up "\d tablename" when not using regexes
Date: 2024-04-10 18:20:48
Message-ID: CALdSSPjTUo=L+qGYW5_zy+DNT+fGCxWQWEcbM6NDOauApn=TMg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi

> 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.

+1

> + appendPQExpBuffer(buf, "(%s OPERATOR(pg_catalog.=) ", namevar);
> + appendStringLiteralConn(buf, &namebuf.data[2], conn);
> + appendPQExpBuffer(buf, "\n OR %s OPERATOR(pg_catalog.=) ",
> + altnamevar);
> + appendStringLiteralConn(buf, &namebuf.data[2], conn);
> + appendPQExpBufferStr(buf, ")\n");

Do we need to force Collaction here like in other branches?
if (PQserverVersion(conn) >= 120000)
appendPQExpBufferStr(buf, " COLLATE pg_catalog.default");

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Ranier Vilela 2024-04-10 18:31:02 Re: Fix resource leak (src/backend/libpq/be-secure-common.c)
Previous Message Tom Lane 2024-04-10 18:15:51 Re: Issue with the PRNG used by Postgres