Hi Enrico,

I like the ON INSERT trigger.....good idea. So perhaps you have a 
"setLogMaxSize" type function in C that allows the client program to say 
"hey, I only want the log to hold a max of 10 000 records".....and then 
I do a select count(*) inside the ON INSERT type trigger and delete 
entries if "num records > max"......

Regarding the locking, I am using a WAL mode database, so I would say we 
are talking microseconds anyway? So I am not too worried.....or should I be?

Thanks

Lynton


On 10/05/2011 15:28, Enrico Thierbach wrote:
>> A round robin queue is fine.  Every so often, to kill off old records do
>>
>> SELECT max(rowid) FROM myTable
>>
>> then in your code subtract from it however many rows you want to keep, then 
>> do
>>
>> DELETE FROM myTable WHERE rowid<  firstToRetain
>>
>> It won't work perfectly but it's simple and fast.
>>
> You could even do something like that in an ON INSERT trigger. And with an 
> AUTOINCREMENT primary key (see http://www.sqlite.org/autoinc.html)
> you would not even have to SELECT max(rowid), as the max rowid is then the 
> rowid of the new record.
>
> As a side note: even when run from a separate thread, inserting the log 
> entries and deleting old entries would lock the database, thus affecting any 
> main thread. You would probably want a separate database for that.
>
> /eno
>
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to