Julio
Julio

Reputation: 318

SQLite SELECT with Limit performance

I have an android app that performs a SELECT * statement over a DB with ~5M records. The query takes about 1 minute to complete and I was wondering whether it can be speed up by using indexes or something else.

SELECT * FROM [TABLE] where timestamp > [TIMESTAMP] ORDER by timestamp ASC LIMIT 0,500

Upvotes: 1

Views: 192

Answers (1)

CL.
CL.

Reputation: 180080

Both the lookup and the sorting in this query can be sped up with an index on the timestamp column:

CREATE INDEX table_timestamp_index ON [TABLE](timestamp);

Upvotes: 1

Related Questions