How to use time-series with Sqlite, with fast time-range queries?
问题 Let's say we log events in a Sqlite database with Unix timestamp column ts : CREATE TABLE data(ts INTEGER, text TEXT); -- more columns in reality and that we want fast lookup for datetime ranges, for example: SELECT text FROM data WHERE ts BETWEEN 1608710000 and 1608718654; Like this, EXPLAIN QUERY PLAN gives SCAN TABLE data which is bad, so one obvious solution is to create an index with CREATE INDEX dt_idx ON data(ts) . Then the problem is solved, but it's rather a poor solution to have to