Re: [PATCH] psql: add \dcs to list all constraints

Tatsuro Yamada <yamatattsu@gmail.com>

From: Tatsuro Yamada <yamatattsu@gmail.com>
To: Álvaro Herrera <alvherre@kurilemu.de>
Cc: Chao Li <li.evan.chao@gmail.com>, Tom Lane <tgl@sss.pgh.pa.us>, Jim Jones <jim.jones@uni-muenster.de>, pgsql-hackers <pgsql-hackers@postgresql.org>
Date: 2026-01-19T13:44:01Z
Lists: pgsql-hackers
Hi Álvaro, and ALL,

>I tested this with one million entries, and the query you proposed was
>more than 1,000 times faster.

Sorry, I just realized that I accidentally added an unnecessary filter
condition to one of the queries.
Specifically, the extra condition was:
    AND n.nspname LIKE 'many_cns'

Because of this, I was not able to measure the two queries under identical
conditions. I will rerun the benchmarks and share the updated results
tomorrow.

> # Summary
> > The following changes are planned for the next patch:
> >
> > - Changed the query (using UNION ALL)
> > - Changed the columns and their order (and the sort order accordingly):
> > - Schema | Table | Type | Name | Definition
> > - Toggle definition verbosity with the + option
> > - Added a test case: \dCN cust*.order*
> >
> > The following items will not be included for now (as they are not
> critical):
> >
> > - Option to switch sort order
> >   (e.g., sort by constraint name vs. table name)
> > - Improved command name checking logic
>
> Yeah, that sounds good to me.
>

Hopefully, I will also be able to submit a new patch along with the revised
measurement results tomorrow.

Regards,
Tatsuro Yamada