Re: [sqlite] Slow SELECT query

2009-09-14 Thread Kees Nuyt
On Mon, 14 Sep 2009 19:58:31 +0200, Kees Nuyt wrote: Oops, that should read > 100 events per second during 15 years > = 4730400 -- ( Kees Nuyt ) c[_] ___ sqlite-users mailing list sqlite-users@sqlite.org http://sqlite.org:8080/cgi-bin/

Re: [sqlite] Slow SELECT query

2009-09-14 Thread Kees Nuyt
On Mon, 14 Sep 2009 06:09:45 -0700 (PDT), wlof wrote: > >Thanks Kees. My app still needs some optimizations, your suggestions look >good. > >One question though: what will happen when id reaches 2^32 - 1 ? (This app >is going to log a lot of events, 24/7 for a long time, so it's not a purely >the

Re: [sqlite] Slow SELECT query

2009-09-14 Thread wlof
Thanks Kees. My app still needs some optimizations, your suggestions look good. One question though: what will happen when id reaches 2^32 - 1 ? (This app is going to log a lot of events, 24/7 for a long time, so it's not a purely theoretical question.) Kees Nuyt wrote: > > On Fri, 4 Sep 2009

Re: [sqlite] Slow SELECT query

2009-09-05 Thread aba . elhaddi
Let's see if we can make the 7pm one. Eh Sent via BlackBerry from T-Mobile -Original Message- From: wlof Date: Fri, 4 Sep 2009 07:52:43 To: Subject: Re: [sqlite] Slow SELECT query Sebastian Bermudez wrote: > > 1) > Ok, change the index to: > CREATE INDEX IF NOT

Re: [sqlite] Slow SELECT query

2009-09-04 Thread Kees Nuyt
On Fri, 4 Sep 2009 06:43:05 -0700 (PDT), wlof wrote: > >Hi everyone, > >I'm using SQLite to maintain a log of events in my application. > >There is only one table: >CREATE TABLE IF NOT EXISTS log (id INTEGER PRIMARY KEY AUTOINCREMENT, >timestamp REAL, event TEXT) > >I don't want the log to grow i

Re: [sqlite] Slow SELECT query

2009-09-04 Thread wlof
Swithun Crowe wrote: > > How about something like: > > DELETE FROM log > WHERE id IN (SELECT id > FROM log > ORDER BY timestamp DESC > LIMIT 1,999); > > Which will only be one delete statement, instead of thousands. I

Re: [sqlite] Slow SELECT query

2009-09-04 Thread wlof
Sebastian Bermudez wrote: > > 1) > Ok, change the index to: > CREATE INDEX IF NOT EXISTS log_idx ON log (timestamp) > > column Id is not used for select... > the Id column just is needed for delete operation. > This seems to have done the trick. The SELECT query now takes ~15 ms. Much better :

Re: [sqlite] Slow SELECT query

2009-09-04 Thread Sebastian Bermudez
1) Ok, change the index to: CREATE INDEX IF NOT EXISTS log_idx ON log (timestamp) column Id is not used for select... the Id column just is needed for delete operation. 2) what's log period your app.have ? Need Year ? Month ? Day ? can you change the REAL data type for an smaller one ? (integ

Re: [sqlite] Slow SELECT query

2009-09-04 Thread Swithun Crowe
Hello w I don't want the log to grow indefinitely, so I periodically call a method w which makes the following query: w SELECT id FROM log ORDER BY timestamp DESC LIMIT 1,999 w A DELETE query is executed on every result. How about something like: DELETE FROM log WHERE id IN (SELEC