Re: Showing index details with \d on psql - Mailing list pgsql-patches

From Tom Lane
Subject Re: Showing index details with \d on psql
Date
Msg-id 2881.1003097274@sss.pgh.pa.us
Whole thread Raw
In response to Re: Showing index details with \d on psql  (Peter Eisentraut <peter_e@gmx.net>)
List pgsql-patches
Peter Eisentraut <peter_e@gmx.net> writes:
> Hmm, shouldn't that be "foo_pkey(thread) (primary key)".  I understand
> what you meant about the brackets, but brackets aren't typically used in
> writing and look artificial.  Maybe something like

>     foo_pkey (thread) -- primary key

Or

    primary key: foo_pkey (thread)
    unique: foo_serial_key (serialcol)

Note my advice nearby for Greg to make use of pg_get_indexdef, which
returns a CREATE INDEX command string for the index.  I have an ulterior
motive here, which is that pg_get_indexdef will deliver useful
information about functional and partial indexes, and I think \d ought
to show that stuff.

In the case of a partial index, anything tacked onto the end of the line
is likely to be confused with the partial index condition.  Consider
these examples, all obtained from the regression database with
    select pg_get_indexdef(oid) from pg_class where relkind='i';

CREATE INDEX onek2_u2_prtl ON onek2 USING btree (unique2) WHERE (stringu1 < 'B'::name)
CREATE INDEX rect2ind ON fast_emp4000 USING rtree (home_base bigbox_ops)
CREATE UNIQUE INDEX func_index_index ON func_index_heap USING btree (textcat(f1, f2))

I suggest that \d should produce entries like this:

Indexes:  onek2_u2_prtl btree (unique2) WHERE (stringu1 < 'B'::name)

Indexes:  rect2ind rtree (home_base bigbox_ops)

Indexes:  unique: func_index_index btree (textcat(f1, f2))

or possibly this would read better:

Indexes:  func_index_index unique btree (textcat(f1, f2))

(s/unique/primary key/ where appropriate).

            regards, tom lane

pgsql-patches by date:

Previous
From: Peter Eisentraut
Date:
Subject: Re: psql: default base and password reading
Next
From: Tom Lane
Date:
Subject: Re: psql: default base and password reading