| From: | Tatsuro Yamada <yamatattsu(at)gmail(dot)com> |
|---|---|
| To: | Álvaro Herrera <alvherre(at)kurilemu(dot)de> |
| Cc: | Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Jim Jones <jim(dot)jones(at)uni-muenster(dot)de>, pgsql-hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | Re: [PATCH] psql: add \dcs to list all constraints |
| Date: | 2026-01-20 10:01:04 |
| Message-ID: | CAOKkKFtPH8f4rHjGSpqYoEOn6cT0p=CuLGa89efbc0uHvcRyWQ@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
Hi Álvaro and ALL,
On Mon, Jan 19, 2026 at 10:44 PM Tatsuro Yamada <yamatattsu(at)gmail(dot)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 | Content-Type | Size |
|---|---|---|
| test_results2.txt | text/plain | 3.2 KB |
| v6-0001-Add-list-constraints-meta-command-dCN-on-psql.patch | application/octet-stream | 39.3 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Peter Eisentraut | 2026-01-20 10:07:47 | Remove redundant AssertVariableIsOfType uses in pg_upgrade |
| Previous Message | Hayato Kuroda (Fujitsu) | 2026-01-20 09:38:42 | RE: Logical Replication of sequences |