Re: \describe*

From: Laurenz Albe <laurenz(dot)albe(at)cybertec(dot)at>
To: Corey Huinker <corey(dot)huinker(at)gmail(dot)com>, pgsql-hackers <pgsql-hackers(at)lists(dot)postgresql(dot)org>
Subject: Re: \describe*
Date: 2018-01-26 09:56:58
Message-ID: 1516960618.2815.24.camel@cybertec.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Corey Huinker wrote:
> Some of the discussions about making psql more user friendly (more tab completions help, exit, etc) got me thinking about other ways that psql could be more friendly, and the one that comes to mind is our terse but cryptic \d* commands.
>
> I think it would be helpful and instructive to have corresponding long-form describe commands.
>
> Take describing schemas. Is \dn intuitive? Not really. In hindsight, you may think "yeah, a schema is a namespace", but you never guessed 'n' on the first try, or the second.
>
> Looking over exec_command_d() a bit, I think it's a bit of a stretch do have each command handle a long form like this:
>
> \describe table my_table
> or
> \describe table verbose my_table
>
> because then each \d-variant has to account for objects named "table" and "verbose" and that's a path to unhappiness.
>
> But if we dash-separated them, then all of the strcmps would be in the 'e' subsection, and each one would just have to know it's long to short translation, and call exec_command_d with the corresponding short command
>
> describe => d
> describe-verbose => d+
> describe-aggregates-verbose => da+
> describe-roles => du
>
> We could even presume the verbose flag in all cases (after all, the user was being verbose...), which would also cut down on tab-completion results, and we could check for interactive mode and display a message like
>
> \describe-schemas (short: \dn+)
>
> so that the person has the opportunity to learn the corresponding short command.
>
> In additional to aiding tab completion discovery of the commands (i.e. typing "\desc" and then hitting tab, it would also make scripts a little more self-documenting.
>
> Thoughts?

I'm somewhat -1 on this.

It would be about as hard to memorize \describe-schemas as it is to memorize \dn:
You'd have to remember that it is "-" and not "_", that it is "describe", not "desc"
and that it is "schemas", not "schema".

Moreover, it would be as awkward to have
\describe-schemas public
as it would be to list all schemas with
\describe-schema

But my strongest criticism is that the \d* commands are for interactive use,
and who wants to type in a long string like that? The beginner won't be able to
guess the correct command, and the experienced user would refuse to use it.

Having said all that, I can imagine that having \desc and \describe as an
alternative to \d would help beginners who come e.g. from Oracle,
but that would mean a change of the current behavior:

test=> \describe
List of foreign servers
Name | Owner | Foreign-data wrapper
--------+----------+----------------------
oracle | postgres | oracle_fdw
(1 row)

This is because \des lists foreign servers, and the rest of the command is ignored.

Yours,
Laurenz Albe

In response to

  • \describe* at 2018-01-26 01:11:00 from Corey Huinker

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Amit Langote 2018-01-26 09:57:03 relispartition for index partitions
Previous Message Amit Langote 2018-01-26 09:17:41 Re: [HACKERS] path toward faster partition pruning