Received: from maia.hub.org (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id AF0A3635FA8 for ; Thu, 11 Mar 2010 11:35:00 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 09801-01 for ; Thu, 11 Mar 2010 15:34:49 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by mail.postgresql.org (Postfix) with ESMTP id DFD77635A4C for ; Thu, 11 Mar 2010 11:34:49 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id o2BFYlKE020644; Thu, 11 Mar 2010 10:34:47 -0500 (EST) To: Dmitriy Igrishin cc: postgres list Subject: Re: Selecting names of indexes that are not dependent on constraints. In-reply-to: References: Comments: In-reply-to Dmitriy Igrishin message dated "Thu, 11 Mar 2010 18:15:56 +0300" Date: Thu, 11 Mar 2010 10:34:47 -0500 Message-ID: <20643.1268321687@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-2.599 tagged_above=-10 required=5 tests=BAYES_00=-2.599 X-Spam-Level: X-Archive-Number: 201003/59 X-Sequence-Number: 33766 Dmitriy Igrishin 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