Re: keeping last 30 entries of a log table - Mailing list pgsql-sql

From Jeff Frost
Subject Re: keeping last 30 entries of a log table
Date
Msg-id Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.com
Whole thread Raw
In response to keeping last 30 entries of a log table  (Jeff Frost <jeff@frostconsultingllc.com>)
List pgsql-sql
On Wed, 21 Jun 2006, Ben K. wrote:

> Just for the sake of alternatives -
>
> create sequence cy30 maxvalue 30 cycle;
>
> insert into log values(select generate_series(1,30), 'dummy');
> INSERT 0 30
>
> update log set des='....' where account_id=(select nextval('cy30'));
> UPDATE 1
>
>
> There are details to consider I guess. For example what if an update fails 
> and the sequence already advanced... Also, since we cycle the id, for 
> sorting, we'll need to add timestamp or something similar.
>

Only problem with this approach is that I need to be able to keep track of the 
last 30 items per each account_id...so each account_id will have his last 30 
messages in the table.


-- 
Jeff Frost, Owner     <jeff@frostconsultingllc.com>
Frost Consulting, LLC     http://www.frostconsultingllc.com/
Phone: 650-780-7908    FAX: 650-649-1954


pgsql-sql by date:

Previous
From: virgi@lettere.unipd.it
Date:
Subject: How to get a result in one row
Next
From: Frank Bax
Date:
Subject: Re: How to get a result in one row