Обсуждение: Selecting names of indexes that are not dependent on constraints.
Hey all,<br /><br />How can I select names of indexes of table (or even whole schema) that are not dependent on constraints?<br/><br />Unfortunately there is no way to select only "independent" indexes from pg_indexes view.<br /><br/>How can I do it?<br /><br />Regards,<br />Dmitriy Igrishin<br />
Of course, I meant the indexes of which constraints do not depend. :)<br /><br /><div class="gmail_quote">2010/3/11 DmitriyIgrishin <span dir="ltr"><<a href="mailto:dmitigr@gmail.com">dmitigr@gmail.com</a>></span><br /><blockquoteclass="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left:1ex;"> Hey all,<br /><br />How can I select names of indexes of table (or even whole schema) that are not dependenton constraints?<br /><br />Unfortunately there is no way to select only "independent" indexes from pg_indexes view.<br/><br />How can I do it?<br /><br />Regards,<br /><font color="#888888">Dmitriy Igrishin<br /></font></blockquote></div><br/>
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