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 indefinitely, so I periodically call a method
which makes the following query:
SELECT id FROM log ORDER BY timestamp DESC LIMIT 10000,9999999

A DELETE query is executed on every result.

The problem is that, on a 1.3MB table (10000 entries), the SELECT query
takes 12 seconds to be executed! This is way too long.

I've added an index on the timestamp column:
CREATE INDEX IF NOT EXISTS log_idx ON log (id, timestamp)

But there is little to no performance improvement.

What am I doing wrong?

-- 
View this message in context: 
http://www.nabble.com/Slow-SELECT-query-tp25294597p25294597.html
Sent from the SQLite mailing list archive at Nabble.com.

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

Reply via email to