looking for optimum select for exported keys

From: Dave Cramer <dave(at)fastcrypt(dot)com>
To: "pgsql-hackers(at)postgresql(dot)org" <pgsql-hackers(at)postgresql(dot)org>
Subject: looking for optimum select for exported keys
Date: 2002-06-04 13:48:56
Message-ID: 1023198536.1427.234.camel@inspiron.cramers
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

The jdbc driver has a method to return the exported keys from a table,
we require essentially what the following select returns, but it is
slow, can anyone suggest ways to optimize it?

Regards,
Dave

SELECT
c.relname as primary,
c2.relname as foreign,
t.tgconstrname,
ic.relname as fkeyname,
af.attnum as fkeyseq,
ipc.relname as pkeyname,
ap.attnum as pkeyseq,
t.tgdeferrable,
t.tginitdeferred,
t.tgnargs,t.tgargs,
p1.proname as updaterule,
p2.proname as deleterule
FROM
pg_trigger t,
pg_trigger t1,
pg_class c,
pg_class c2,
pg_class ic,
pg_class ipc,
pg_proc p1,
pg_proc p2,
pg_index if,
pg_index ip,
pg_attribute af,
pg_attribute ap
WHERE
(t.tgrelid=c.oid
AND t.tgisconstraint
AND t.tgconstrrelid=c2.oid
AND t.tgfoid=p1.oid
and p1.proname like '%%upd')

and
(t1.tgrelid=c.oid
and t1.tgisconstraint
and t1.tgconstrrelid=c2.oid
AND t1.tgfoid=p2.oid
and p2.proname like '%%del')

AND c2.relname='users'

AND
(if.indrelid=c.oid
AND if.indexrelid=ic.oid
and ic.oid=af.attrelid
AND if.indisprimary)

and
(ip.indrelid=c2.oid
and ip.indexrelid=ipc.oid
and ipc.oid=ap.attrelid
and ip.indisprimary)
;

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Vergoz Michael 2002-06-04 14:51:06 clustering
Previous Message Tille, Andreas 2002-06-04 13:09:35 Re: Cygwin / Debian dpkg / PostgreSQL / KDE2 and 3