Re: keeping last 30 entries of a log table
| От | Jeff Frost |
|---|---|
| Тема | Re: keeping last 30 entries of a log table |
| Дата | |
| Msg-id | Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.com обсуждение исходный текст |
| Ответ на | keeping last 30 entries of a log table (Jeff Frost <jeff@frostconsultingllc.com>) |
| Список | 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 по дате отправления: