Re: remove indexes on a column?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Vance Maverick <vmaverick(at)pgp(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: remove indexes on a column?
Date: 2008-09-10 05:01:40
Message-ID: 16134.1221022900@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Vance Maverick <vmaverick(at)pgp(dot)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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message 小波 顾 2008-09-10 05:17:55 Re: PostgreSQL process architecture question.
Previous Message Vance Maverick 2008-09-10 04:50:28 Re: remove indexes on a column?