I need to write a function which inserts a log entry in a log table and only
keeps the last 30 records. I was thinking of using a subquery similar to the
following:
insert into log (account_id, message) values (1, 'this is a test);
delete from log where account_id = 1 and id not in ( select id
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 consid
On Tue, 20 Jun 2006, Dirk Jagdmann wrote:
Column id should be indexed indeed. Anyway, I'm not sure about any
performance improvement using that last method, as the most consuming
operation might be the DELETE operation, not really the SELECT operation,
when dealing with a huge volume of data.
Column id should be indexed indeed. Anyway, I'm not sure about any performance
improvement using that last method, as the most consuming operation might be
the DELETE operation, not really the SELECT operation, when dealing with a huge
volume of data.
why worry, there are a maximum of 30 Ent
> >> insert into log (account_id, message) values (1, 'this is a test);
> >> delete from log where account_id = 1 and id not in ( select id from log
> >>where account_id = 1 order by timestamp desc limit 30);
> >>
> >> I'm wondering if there is a more performance oriented method of doing
> the
On Sat, 17 Jun 2006, Daniel CAUNE wrote:
insert into log (account_id, message) values (1, 'this is a test);
delete from log where account_id = 1 and id not in ( select id from log
where account_id = 1 order by timestamp desc limit 30);
I'm wondering if there is a more performance oriented me
> I need to write a function which inserts a log entry in a log table and
> only
> keeps the last 30 records. I was thinking of using a subquery similar to
> the
> following:
>
> insert into log (account_id, message) values (1, 'this is a test);
> delete from log where account_id = 1 and id not i
I need to write a function which inserts a log entry in a log table and only
keeps the last 30 records. I was thinking of using a subquery similar to the
following:
insert into log (account_id, message) values (1, 'this is a test);
delete from log where account_id = 1 and id not in ( select id