pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Selecting names of indexes that are not dependent on constraints.
3+ messages / 2 participants
[nested] [flat]

* Selecting names of indexes that are not dependent on constraints.
@ 2010-03-11 15:15 Dmitriy Igrishin <dmitigr@gmail.com>
  2010-03-11 15:20 ` Re: Selecting names of indexes that are not dependent on constraints. Dmitriy Igrishin <dmitigr@gmail.com>
  2010-03-11 15:34 ` Re: Selecting names of indexes that are not dependent on constraints. Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: Dmitriy Igrishin @ 2010-03-11 15:15 UTC (permalink / raw)
  To: pgsql-sql

Hey all,

How can I select names of indexes of table (or even whole schema) that are
not dependent on constraints?

Unfortunately there is no way to select only "independent" indexes from
pg_indexes view.

How can I do it?

Regards,
Dmitriy Igrishin

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Selecting names of indexes that are not dependent on constraints.
  2010-03-11 15:15 Selecting names of indexes that are not dependent on constraints. Dmitriy Igrishin <dmitigr@gmail.com>
@ 2010-03-11 15:20 ` Dmitriy Igrishin <dmitigr@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Dmitriy Igrishin @ 2010-03-11 15:20 UTC (permalink / raw)
  To: pgsql-sql

Of course, I meant the indexes of which constraints do not depend. :)

2010/3/11 Dmitriy Igrishin <dmitigr@gmail.com>

> Hey all,
>
> How can I select names of indexes of table (or even whole schema) that are
> not dependent on constraints?
>
> Unfortunately there is no way to select only "independent" indexes from
> pg_indexes view.
>
> How can I do it?
>
> Regards,
> Dmitriy Igrishin
>

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: Selecting names of indexes that are not dependent on constraints.
  2010-03-11 15:15 Selecting names of indexes that are not dependent on constraints. Dmitriy Igrishin <dmitigr@gmail.com>
@ 2010-03-11 15:34 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2010-03-11 15:34 UTC (permalink / raw)
  To: Dmitriy Igrishin <dmitigr@gmail.com>; +Cc: pgsql-sql

Dmitriy Igrishin <dmitigr@gmail.com> writes:
> How can I select names of indexes of table (or even whole schema) that are
> not dependent on constraints?

Right at the moment, the only reliable way to tell whether an index is
associated with a constraint is to look for a pg_depend entry linking
the two.  Be careful to consider only "internal" dependencies, else you
may be fooled by foreign-key constraints that depend on indexes.
If you look into the pg_dump source code you will find an example.

9.0 will make this a tad simpler by keeping a "conindid" column in
pg_constraint.

			regards, tom lane



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2010-03-11 15:34 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2010-03-11 15:15 Selecting names of indexes that are not dependent on constraints. Dmitriy Igrishin <dmitigr@gmail.com>
2010-03-11 15:20 ` Dmitriy Igrishin <dmitigr@gmail.com>
2010-03-11 15:34 ` Tom Lane <tgl@sss.pgh.pa.us>

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