If your search is slow, analyze your history!

I rebuilt my history.db, and interactive search felt so laggy and CPU usage was high. Debug logging showed that the SQL query took nearly one second to run!

An index was missing? I thought. So I compared my new history.db and the old one, and it turned out two tables were missing: sqlite_stat1 and sqlite_stat4. A simple web search told me they were used for storing statistics. So I ran:

ANALYZE history;

And performance came back to normal!

I don’t know why they were there before my rebuild and not after, but I hope this can help others.

1 Like