From: | Jeff Frost <jeff(at)frostconsultingllc(dot)com> |
---|---|
To: | "Ben K(dot)" <bkim(at)coe(dot)tamu(dot)edu> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: keeping last 30 entries of a log table |
Date: | 2006-06-21 17:57:24 |
Message-ID: | Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)frostconsultingllc(dot)com>
Frost Consulting, LLC http://www.frostconsultingllc.com/
Phone: 650-780-7908 FAX: 650-649-1954
From | Date | Subject | |
---|---|---|---|
Next Message | Frank Bax | 2006-06-21 18:06:55 | Re: How to get a result in one row |
Previous Message | Ben K. | 2006-06-21 17:49:20 | Re: keeping last 30 entries of a log table |