Re: [PATCH] psql: add \dcs to list all constraints - Mailing list pgsql-hackers

From Tatsuro Yamada
Subject Re: [PATCH] psql: add \dcs to list all constraints
Date
Msg-id CAOKkKFtPH8f4rHjGSpqYoEOn6cT0p=CuLGa89efbc0uHvcRyWQ@mail.gmail.com
Whole thread Raw
In response to Re: [PATCH] psql: add \dcs to list all constraints  (Tatsuro Yamada <yamatattsu@gmail.com>)
Responses Re: [PATCH] psql: add \dcs to list all constraints
List pgsql-hackers
Hi Álvaro and ALL,

On Mon, Jan 19, 2026 at 10:44 PM Tatsuro Yamada <yamatattsu@gmail.com> wrote:
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.

The error in the query has been fixed, and the execution times were
measured again.
As a result, there was no significant difference in execution time
between the two queries (see the attached test_result2.txt).
When comparing the cost of the top node, the original query has a
slightly lower cost, so I decided to keep it as is.
 

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

The patch (v6) incorporates the changes listed above.
Note that, as mentioned earlier, the query itself was not changed.

Below is an example of the result set after the corrections 
(from the regression test):

\dCN con_*
                   List of constraints
 Schema | Table |   Type    |            Name            
--------+-------+-----------+----------------------------
 public | con_c | NOT NULL  | con_c_primary_col_not_null
 public | con_c | PK        | con_c_pkey
 public | con_p | CHECK     | con_p_check_col_check
 public | con_p | EXCLUSION | con_p_exclusion
 public | con_p | FK        | con_p_foreign_col_fkey
 public | con_p | NOT NULL  | con_p_notnull_col_not_null
 public | con_p | NOT NULL  | con_p_primary_col_not_null
 public | con_p | PK        | con_p_pkey
 public | con_p | TRIGGER   | con_p_trigger
 public | con_p | UNIQUE    | con_p_unique_col_key
(10 rows)


What do you think?
Please find the attached patch.

Regards,
Tatsuro Yamada
Attachment

pgsql-hackers by date:

Previous
From: "Hayato Kuroda (Fujitsu)"
Date:
Subject: RE: Logical Replication of sequences
Next
From: Peter Eisentraut
Date:
Subject: Remove redundant AssertVariableIsOfType uses in pg_upgrade