pg.ddx.io  pgsql-interfaces@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Jason E. Stewart <jason@openinformatics.com>
To: pgsql-interfaces@postgresql.org
Subject: Re: Frontend/Backend protocol changes?
Date: 22 Nov 2002 16:17:18 -0700
Message-ID: <87d6ox6vpd.fsf@openinformatics.com> (raw)
In-Reply-To: <28828.1038004623@sss.pgh.pa.us>
References: <87of8ha7ch.fsf@openinformatics.com>
	<25204.1037984494@sss.pgh.pa.us>
	<877kf5a5md.fsf@openinformatics.com>
	<26177.1037992260@sss.pgh.pa.us>
	<87ptsx70gz.fsf@openinformatics.com>
	<28828.1038004623@sss.pgh.pa.us>

"Tom Lane" <tgl@sss.pgh.pa.us> writes:

> "Jason E. Stewart" <jason@openinformatics.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
updated.

> (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
table?

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

Cheers,
jas.



view thread (14+ messages)  latest in thread

Message-ID: <87d6ox6vpd.fsf@openinformatics.com>
Permalink:  ../87d6ox6vpd.fsf@openinformatics.com/
Also on:    postgresql.org/message-id/87d6ox6vpd.fsf@openinformatics.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-interfaces@postgresql.org
  Cc: jason@openinformatics.com
  Subject: Re: Frontend/Backend protocol changes?
  In-Reply-To: <87d6ox6vpd.fsf@openinformatics.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox