Re: Find out the indexed columns

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Find out the indexed columns
Дата
Msg-id 337746.1683553135@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: Find out the indexed columns  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Find out the indexed columns  (Nikhil Ingale <niks.bgm@gmail.com>)
Список pgsql-admin
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'::regclassand objid = 'ti'::regclass; 
   pg_describe_object
-------------------------
 table t
 column f1 of table t
 function fipshash(text)
(3 rows)

            regards, tom lane



В списке pgsql-admin по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: Find out the indexed columns
Следующее
От: Nikhil Ingale
Дата:
Сообщение: Re: Find out the indexed columns