SQLite – Should I add some indexes even if select queries are fast

indexperformanceperformance-tuningsqlite

I have a SQLite DB with only one table of size ~1.5 MB (in fact, there are ~30 tables in total, but each table is stored in a separate .db file).

When I use EXPLAIN QUERY PLAN for any table, it shows a full table scan, which as far as I know is not good. However, non of the tables have index and also, the speed of select queries are fast.

So, I was wondering whether I should add some indexes on our tables or just keep them as they are? (Now, tables have max 5k rows and in future they may go maximum up to 100k rows).

PS. number of selects and inserts are almost the same..

All ideas are highly appreciated.

Best Answer

Now, tables have max 5k rows and in future they may go maximum up to 100k rows

In cases like this, where time and resource permits, the best way to check this is to manufacture realistic looking data of that size and test your application against that to see how well it scales (or if it doesn't, where the bottlenecks lie). Make sure your data is realistic though: ~100,000 identical rows won't be a good test as the indexes will not be selective enough to be useful, likewise truly random numbers in the column where the data is expected to "bunch" would also not be the most useful test.