From: Richard Ellis <rellis9@yahoo.com>
To: pgsql-performance@postgresql.org
Subject: Re: Indexing question
Date: Fri, 29 Aug 2003 12:58:51 -0400
Message-ID: <20030829165850.GA28458@i386.dp100.com> (raw)
In-Reply-To: <027701c36e40$2851aef0$b696a8c0@APR>
References: <012f01c36dfa$0f4a8760$b696a8c0@APR>
<3F4EFAB6.7030104@klaster.net>
<015f01c36e02$134fe960$b696a8c0@APR>
<3F4F07CE.6090803@klaster.net>
<018c01c36e09$4893e980$b696a8c0@APR>
<3F4F1575.8090600@klaster.net>
<01bf01c36e0d$18769280$b696a8c0@APR>
<15992.1062165614@sss.pgh.pa.us>
<027701c36e40$2851aef0$b696a8c0@APR>
On Fri, Aug 29, 2003 at 05:13:52PM +0200, Alexander Priem wrote:
> Well, the intention is to hold every record that ever existed in the table.
> Therefore, records do not get deleted, but they get a date in the
> deleteddate field. This way, we can track what changes were made to the
> table(s).
>
> So if a record gets 'deleted', the field 'deleted' is set to today's date.
> If a record gets 'updated', a new record is made containing the new data,
> and the old record is marked as 'deleted'.
>
> So the percentage of 'deleted' records will grow with time, if you
> understand what I mean.
Did you consider a two table implimentation. 1 table "live_table"
containing the non-deleted records, a second table "deleted_table"
containing the deleted records, along with the "deleted_date" field. Keep
the two in sync column type/number wise, and use a before delete trigger
function on "live_table" to actually insert a copy of the deleted row plus
"deleted_date" into "deleted_table" before performing the delete on
"live_table".
You could also use a before update trigger to keep old copies of updated
records in the same way.
Then you would only incur the performance loss of scanning/etc. the deleted
records when you actually need to pull up deleted plus live records.
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-performance@postgresql.org
Cc: rellis9@yahoo.com
Subject: Re: Indexing question
In-Reply-To: <20030829165850.GA28458@i386.dp100.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