From: Tom Lane <tgl@sss.pgh.pa.us>
To: Nikhil Ingale <niks.bgm@gmail.com>
Cc: pgsql-admin@lists.postgresql.org
Subject: Re: Find out the indexed columns
Date: Mon, 08 May 2023 09:38:55 -0400
Message-ID: <337746.1683553135@sss.pgh.pa.us> (raw)
In-Reply-To: <334991.1683552353@sss.pgh.pa.us>
References: <CALXkTpw1Sf_TPLjJxWc-bg--21A8wTb126G=zeGqRGh9GgT3Ww@mail.gmail.com>
<334991.1683552353@sss.pgh.pa.us>
I wrote:
> You could get back the column name(s) by joining to pg_attribute,
Oh, another possible approach is to use pg_describe_object,
which'd be interesting if you also want to handle non-column
dependencies. For example,
regression=# drop table t;
DROP TABLE
regression=# create table t(f1 text);
CREATE TABLE
regression=# create index ti on t (fipshash(f1));
CREATE INDEX
regression=# select * from pg_depend where classid = 'pg_class'::regclass and objid = 'ti'::regclass;
classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptype
---------+-------+----------+------------+----------+-------------+---------
1259 | 48632 | 0 | 1259 | 48627 | 0 | a
1259 | 48632 | 0 | 1259 | 48627 | 1 | a
1259 | 48632 | 0 | 1255 | 16501 | 0 | n
(3 rows)
regression=# select pg_describe_object(refclassid, refobjid, refobjsubid) from pg_depend where classid = 'pg_class'::regclass and objid = 'ti'::regclass;
pg_describe_object
-------------------------
table t
column f1 of table t
function fipshash(text)
(3 rows)
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, niks.bgm@gmail.com, pgsql-admin@lists.postgresql.org
Subject: Re: Find out the indexed columns
In-Reply-To: <337746.1683553135@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox