From: Jeff Frost <jeff@frostconsultingllc.com>
To: Ben K. <bkim@coe.tamu.edu>
Cc: pgsql-sql@postgresql.org
Subject: Re: keeping last 30 entries of a log table
Date: Wed, 21 Jun 2006 10:57:24 -0700 (PDT)
Message-ID: <Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.com> (raw)
In-Reply-To: <Pine.GSO.4.64.0606211227020.20083@coe.tamu.edu>
References: <Pine.LNX.4.64.0606161924550.27250@glacier.frostconsultingllc.com>
<Pine.GSO.4.64.0606211227020.20083@coe.tamu.edu>
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
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 from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-sql@postgresql.org
Cc: jeff@frostconsultingllc.com, bkim@coe.tamu.edu
Subject: Re: keeping last 30 entries of a log table
In-Reply-To: <Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.com>
References: <Pine.LNX.4.64.0606161924550.27250@glacier.frostconsultingllc.com> <Pine.GSO.4.64.0606211227020.20083@coe.tamu.edu> <Pine.LNX.4.64.0606211055591.27250@glacier.frostconsultingllc.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