Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAzIG-0004bl-UO for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 16:28:33 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1iAzIF-0000Tj-KL for pgsql-performance@arkaria.postgresql.org; Thu, 19 Sep 2019 16:28:31 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1iAzIF-0000TU-8S for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 16:28:31 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1iAzI8-0007bi-PL for pgsql-performance@lists.postgresql.org; Thu, 19 Sep 2019 16:28:30 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id x8JGSM5A024572; Thu, 19 Sep 2019 12:28:22 -0400 From: Tom Lane To: Mariel Cherkassky cc: pgsql-performance@lists.postgresql.org Subject: Re: comparing output of internal pg tables of referenced tables In-reply-to: References: Comments: In-reply-to Mariel Cherkassky message dated "Thu, 19 Sep 2019 18:50:44 +0300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <24570.1568910502.1@sss.pgh.pa.us> Date: Thu, 19 Sep 2019 12:28:22 -0400 Message-ID: <24571.1568910502@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Mariel Cherkassky writes: > 2)select conname, (select r.relname from pg_class r where r.oid = > c.confrelid) as orig_table, (select array_agg(attname) from pg_attribute > where attrelid = c.confrelid and ARRAY[attnum] <@ c.conkey) as > orig_cols, (select r.relname from pg_class r where r.oid = c.conrelid) as > foreign_table, (select array_agg(attname) from pg_attribute where > attrelid = c.conrelid and ARRAY[attnum] <@ c.conkey) as foreign_cols from > pg_constraint c where c.confrelid = (select oid from pg_class where > relname = '*my_table*') and c.contype='f' > On the second output in the orig_cols I got a few weird outputs like > : {........pg.dropped.5........} or even a columns that doesnt have a > unique index (just a random column from the orig_table). You need to be looking at confkey not conkey for the columns in the confrelid table. regards, tom lane