Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pw14v-0004Vw-Em for pgsql-admin@arkaria.postgresql.org; Mon, 08 May 2023 13:39:01 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1pw14u-0003NW-Dj for pgsql-admin@arkaria.postgresql.org; Mon, 08 May 2023 13:39:00 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1pw14u-0003NN-3F for pgsql-admin@lists.postgresql.org; Mon, 08 May 2023 13:39:00 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1pw14r-001N77-HW for pgsql-admin@lists.postgresql.org; Mon, 08 May 2023 13:38:59 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 348DctEb337747; Mon, 8 May 2023 09:38:55 -0400 From: Tom Lane To: Nikhil Ingale cc: pgsql-admin@lists.postgresql.org Subject: Re: Find out the indexed columns In-reply-to: <334991.1683552353@sss.pgh.pa.us> References: <334991.1683552353@sss.pgh.pa.us> Comments: In-reply-to Tom Lane message dated "Mon, 08 May 2023 09:25:53 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <337745.1683553135.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 08 May 2023 09:38:55 -0400 Message-ID: <337746.1683553135@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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=3D# drop table t; DROP TABLE regression=3D# create table t(f1 text); CREATE TABLE regression=3D# create index ti on t (fipshash(f1)); CREATE INDEX regression=3D# select * from pg_depend where classid =3D 'pg_class'::regcl= ass and objid =3D 'ti'::regclass; classid | objid | objsubid | refclassid | refobjid | refobjsubid | deptyp= e = ---------+-------+----------+------------+----------+-------------+-------= -- 1259 | 48632 | 0 | 1259 | 48627 | 0 | a 1259 | 48632 | 0 | 1259 | 48627 | 1 | a 1259 | 48632 | 0 | 1255 | 16501 | 0 | n (3 rows) regression=3D# select pg_describe_object(refclassid, refobjid, refobjsubid= ) from pg_depend where classid =3D 'pg_class'::regclass and objid =3D 'ti'= ::regclass; pg_describe_object = ------------------------- table t column f1 of table t function fipshash(text) (3 rows) regards, tom lane