Re: comparing output of internal pg tables of referenced tables

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com>
Cc: pgsql-performance(at)lists(dot)postgresql(dot)org
Subject: Re: comparing output of internal pg tables of referenced tables
Date: 2019-09-19 16:28:22
Message-ID: 24571.1568910502@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Mariel Cherkassky <mariel(dot)cherkassky(at)gmail(dot)com> 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

In response to

Responses

Browse pgsql-performance by date

  From Date Subject
Next Message Andreas Kretschmer 2019-09-19 16:50:11 Re: Delete huge Table under XFS
Previous Message Joao Junior 2019-09-19 15:59:55 Delete huge Table under XFS