Re: remove indexes on a column? - Mailing list pgsql-general

From Tom Lane
Subject Re: remove indexes on a column?
Date
Msg-id 16134.1221022900@sss.pgh.pa.us
Whole thread Raw
In response to Re: remove indexes on a column?  (Vance Maverick <vmaverick@pgp.com>)
List pgsql-general
Vance Maverick <vmaverick@pgp.com> writes:
> Perfect!  Looks like I can get the names of the existing indexes by
> doing

> SELECT dep.relname
>  FROM pg_attribute col, pg_class tab, pg_depend pd, pg_class dep
>  WHERE tab.relname = 'mytable'
>   AND col.attname = 'mycolumn'
>   AND col.attrelid = tab.oid
>   AND pd.refobjid = tab.oid
>   AND pd.refobjsubid = col.attnum
>   AND pd.objid = dep.oid
>   AND dep.relkind = 'i';

Too tired/lazy to check right now, but you should also look into
what the pg_depend representation is for constraints: I have a feeling
that a unique or primary key constraint yields a pg_depend structure
with an indirect linkage through a pg_constraint entry.

Also, the above query doesn't seem very schema-safe: what if there
are multiple tables named mytable?  Personally I'd try something
like tab.oid = 'mytable'::regclass instead of the relname test.

            regards, tom lane

pgsql-general by date:

Previous
From: Vance Maverick
Date:
Subject: Re: remove indexes on a column?
Next
From: 小波 顾
Date:
Subject: Re: PostgreSQL process architecture question.