EDIT:
This answer did not solve the problem, but sqlite will use a LIKE
query optimization if certain conditions are true. You must not use a wildcard as the first character of your search string. I'll leave this answer here since it might help with other LIKE
optimizations.
Old Answer:
I have done troubleshooting on sqlite performance before. Open up your database by typing sqlite3 databasefile
.
These are some of the commands I use in the sqlite3 command line:
.help
.timer ON
.explain ON -- optional
explain query plan SELECT BLAH FROM BLAH WHERE BLAH
If you see a SCAN
, that's bad. If you see a SEARCH
it is using an index. You can add an index to improve SELECT performance.
You could try an index like this in the sqlite3 command line:
CREATE INDEX flows_idx1 ON flows (buffer);
This will create the index as part of the databas schema, meaning you do not have to recreate it. It will henceforth exist, unless you drop
it. The sqlite3 query optimizer will look at your SELECT
and see if the index will help speed it up. You do not need to change your SELECT
query at all.
See also the Sqlite optimization documentation.