Skip site navigation (1) Skip section navigation (2)

Re: Frontend/Backend protocol changes?

From: "Jason E(dot) Stewart" <jason(at)openinformatics(dot)com>
To: pgsql-interfaces(at)postgresql(dot)org
Subject: Re: Frontend/Backend protocol changes?
Date: 2002-11-22 23:17:18
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-interfaces
"Tom Lane" <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

> "Jason E. Stewart" <jason(at)openinformatics(dot)com> writes:
> > Are all the RI_ConstraintTrigger_XXXXX triggers on _other_ tables that
> > affect this table in some way??? Because Audit shouldn't have any. 
> You should check, but I think those are all going to be ON UPDATE or ON
> DELETE triggers, if they all appear to be in pairs.  You probably have a
> bunch of FK's referencing Audit from other tables?  If so, they are not
> hurting your insert performance.  But an update or delete in Audit would
> be expensive.

Right, I removed all the fkey constraints and they all
disappeared. The audit table is never updated, only inserted into.

BTW, is there some other way to have all rows in a table automatically
timestamped? That would satisfy 99% of what I need. Maintaining the
trail of audits could then be done for those rare cases where data is

> (BTW, I'm having a hard time visualizing why an audit-trail table would
> be referenced by FKs from other tables.)

Maybe it's a stupid design, but each table that needs on audit trail
on it's rows has an audit_fk foreign key column. When I insert a row
into that table, the trigger creates a new audit in the audit table
and sets the audit_fk for the table.

I suppose I could do it the other way around, put the fkey column in
the Audit table, and either reference that rows oid, or the pkey value
of the table entry (all the pkey values are drawn from the same
sequence so they are unique across tables).

But that would mean searching the Audit table to find a given entry,
I can make an index for that column which would speed it up, but it
would never be as fast as holding the audit_fk in the other table. 

Is there some advantage I don't see to having the column in the Audit

Actually searching the Audit table is a very rare occurrence (only
needed if somebody messed up some data and you want to find the


In response to


pgsql-interfaces by date

Next:From: Bruce BadgerDate: 2002-11-22 23:59:37
Subject: Re: Frontend/Backend protocol changes?
Previous:From: Tom LaneDate: 2002-11-22 22:37:03
Subject: Re: Frontend/Backend protocol changes?

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group