Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1d3h85-0000af-PU for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Apr 2017 10:58:33 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1d3h85-0003Mw-36 for pgsql-bugs@arkaria.postgresql.org; Thu, 27 Apr 2017 10:58:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d3h7O-0002Ab-SQ for pgsql-bugs@postgresql.org; Thu, 27 Apr 2017 10:57:50 +0000 Received: from lungold.riddles.org.uk ([82.68.208.19]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1d3h7M-0003qo-0t for pgsql-bugs@postgresql.org; Thu, 27 Apr 2017 10:57:50 +0000 Received: from [192.168.127.1] (port=48893 helo=caithnard.riddles.org.uk) by lungold.riddles.org.uk with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.88 (FreeBSD)) (envelope-from ) id 1d3h7K-0006NB-03; Thu, 27 Apr 2017 10:57:46 +0000 Received: from [127.0.0.1] (port=43267 helo=caithnard.riddles.org.uk) by caithnard.riddles.org.uk with esmtp (Exim 4.89 (FreeBSD)) (envelope-from ) id 1d3h7J-0003pL-A9; Thu, 27 Apr 2017 10:57:45 +0000 From: Andrew Gierth To: Roy Brokvam Cc: pgsql-bugs@postgresql.org Subject: Re: Meaning of pg_constraint.conindid for foreign keys In-Reply-To: (Roy Brokvam's message of "Thu, 27 Apr 2017 12:29:50 +0200") Message-ID: <871sseuo4v.fsf@news-spur.riddles.org.uk> References: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/25.1 (berkeley-unix) Date: Thu, 27 Apr 2017 11:57:45 +0100 MIME-Version: 1.0 Content-Type: text/plain X-Pg-Spam-Score: -1.9 (-) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org >>>>> "Roy" == Roy Brokvam writes: Roy> After investigating further, saw that conindid contained the oid Roy> of the referenced table's primary key, not the oid of the index Roy> "implementing" the foreign key. FKs aren't implemented using an index on the referencing table, only on the referenced table. i.e. given: CREATE TABLE foo (id integer PRIMARY KEY); CREATE TABLE bar (foo_id integer REFERENCES foo); the constraint depends on the existence of the index foo_pkey (and it's this one which is recorded in the system catalogs), but there is no index at all on bar; even if you created an index on bar(foo_id), it would not be associated in any way with the FK constraint (though it would improve the performance of updates/deletes in foo, because the query issued by the constraint check would likely use it). So you're looking in the wrong place. -- Andrew (irc:RhodiumToad) -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs