Re: Postgresql "FIFO" Tables, How-To ?

From: "Kirill Ponazdyr" <softlist(at)codeangels(dot)com>
To: "Nigel J(dot) Andrews" <nandrews(at)investsystems(dot)co(dot)uk>
Cc: "pg_general" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Postgresql "FIFO" Tables, How-To ?
Date: 2003-07-16 16:18:09
Message-ID: 2749.192.168.1.3.1058372289.squirrel@www.codeangels.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

>> Hello,
>>
>> We are currently working on a project where we need to limit number of
>> records in a table to a certain number. As soon as the number has been
>> reached, for each new row the oldest row should be deleted (Kinda FIFO),
>> thus keeping a total number of rows at predefined number.
>>
>> The actual limits would be anywhere from 250k to 10mil rows per table.
>>
>> It would be great if this could be achieved by RDBMS engine itself, does
>> Postgres supports this kind of tables ? And if not, what would be the
>> most
>> elegant soluion to achieve our goal in your oppinion ?
>>
>
> An after insert trigger springs to mind.

Ouch, this means that for every insert we would have to trigger a
procedure which will:

COUNT
IF > Limit
DELETE OLDEST

This would be pretty much damn ressource intensive on a table with million
of records, would not it ?

Regards

--
Kirill Ponazdyr
Technical Director
Codeangels Solutions GmbH
Tel: +41 (0)43 844 90 10
Fax: +41 (0)43 844 90 12
Web: www.codeangels.com

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Bruno Wolff III 2003-07-16 16:18:10 Re: IPv4 addresses, unsigned integers, space
Previous Message Shridhar Daithankar 2003-07-16 16:16:17 Re: Postgresql "FIFO" Tables, How-To ?