Обсуждение: [PATCH] psql: add size-based sorting options (O/o) for tables and indexes
Hello, This patch adds two new meta-command modifiers for \dt(+) and \di(+): - O : sort by total relation size descending - o : sort by total relation size ascending This makes it easier to identify the largest tables and indexes without writing custom SQL queries. Help message (\?) is updated to reflect the new options. regards, -- M.Atıf Ceylan
Вложения
Re: [PATCH] psql: add size-based sorting options (O/o) for tables and indexes
От
"Euler Taveira"
Дата:
On Wed, Nov 26, 2025, at 4:48 AM, M.Atıf Ceylan wrote: > Hello, > This patch adds two new meta-command modifiers for \dt(+) and \di(+): > > - O : sort by total relation size descending > - o : sort by total relation size ascending > Thanks for your contribution. Register your patch in the next commitfest [1] so we don't loose track of it. I didn't look at your patch but I was wondering if a general solution isn't a better way to add this feature. I wouldn't modify these specific psql meta-commands, instead, I would add a new psql meta-command that defines this property for all objects if applicable. \sort [ name | size [ asc | desc ] ] I thought about a list to be cover other sort cases too but if things starting to be complex, it is time to write your own query. With a parameter, it appends the ORDER BY clause in the SQL commands executed by psql if applicable. Without a parameter, it uses the current behavior. [1] https://commitfest.postgresql.org/57/ -- Euler Taveira EDB https://www.enterprisedb.com/
Re: [PATCH] psql: add size-based sorting options (O/o) for tables and indexes
От
Pavel Stehule
Дата:
Hi
st 26. 11. 2025 v 13:44 odesílatel Euler Taveira <euler@eulerto.com> napsal:
On Wed, Nov 26, 2025, at 4:48 AM, M.Atıf Ceylan wrote:
> Hello,
> This patch adds two new meta-command modifiers for \dt(+) and \di(+):
>
> - O : sort by total relation size descending
> - o : sort by total relation size ascending
>
Thanks for your contribution. Register your patch in the next commitfest [1] so
we don't loose track of it.
I didn't look at your patch but I was wondering if a general solution isn't a
better way to add this feature. I wouldn't modify these specific psql
meta-commands, instead, I would add a new psql meta-command that defines this
property for all objects if applicable.
\sort [ name | size [ asc | desc ] ]
I thought about a list to be cover other sort cases too but if things starting
to be complex, it is time to write your own query.
It is big question - if there should be specialized metacommand, or just variable or \pset setting
it can be
\set PREFERRED_ORDER size_desc
\pset preffered_order size_desc
With a parameter, it appends the ORDER BY clause in the SQL commands executed by
psql if applicable. Without a parameter, it uses the current behavior.
There were a lot of proposals related to this topic some years ago. I wrote a lot of variants of this patch
Generic design is very big, and solutions like proposed are not generic :-). We talked about this feature for maybe more than one year, and we didn't find a generally acceptable design.
At the end I wrote pspg, and the sort can be done (over result) there. Using a vertical cursor (column cursor) is very natural and user friendly.
Regards
Pavel
[1] https://commitfest.postgresql.org/57/
--
Euler Taveira
EDB https://www.enterprisedb.com/
Re: [PATCH] psql: add size-based sorting options (O/o) for tables and indexes
От
Pavel Stehule
Дата:
st 26. 11. 2025 v 14:01 odesílatel Pavel Stehule <pavel.stehule@gmail.com> napsal:
Hist 26. 11. 2025 v 13:44 odesílatel Euler Taveira <euler@eulerto.com> napsal:On Wed, Nov 26, 2025, at 4:48 AM, M.Atıf Ceylan wrote:
> Hello,
> This patch adds two new meta-command modifiers for \dt(+) and \di(+):
>
> - O : sort by total relation size descending
> - o : sort by total relation size ascending
>
Thanks for your contribution. Register your patch in the next commitfest [1] so
we don't loose track of it.
I didn't look at your patch but I was wondering if a general solution isn't a
better way to add this feature. I wouldn't modify these specific psql
meta-commands, instead, I would add a new psql meta-command that defines this
property for all objects if applicable.
\sort [ name | size [ asc | desc ] ]
I thought about a list to be cover other sort cases too but if things starting
to be complex, it is time to write your own query.It is big question - if there should be specialized metacommand, or just variable or \pset settingit can be\set PREFERRED_ORDER size_desc\pset preffered_order size_desc
With a parameter, it appends the ORDER BY clause in the SQL commands executed by
psql if applicable. Without a parameter, it uses the current behavior.There were a lot of proposals related to this topic some years ago. I wrote a lot of variants of this patchGeneric design is very big, and solutions like proposed are not generic :-). We talked about this feature for maybe more than one year, and we didn't find a generally acceptable design.
At the end I wrote pspg, and the sort can be done (over result) there. Using a vertical cursor (column cursor) is very natural and user friendly.RegardsPavel
[1] https://commitfest.postgresql.org/57/
--
Euler Taveira
EDB https://www.enterprisedb.com/