Hi Chris, the docs at https://www.sqlite.org/pragma.html#pragma_optimize suggest to run "PRAGMA optimize" at the end of the connection, or periodically--not at the beginning. That makes sense since it has to be able to see which queries are emitted in order to know what to optimize. Also, docs say: > The query planner used sqlite_stat1-style statistics for one or more indexes > of the table at some point during the lifetime of the current connection. That probably means one would have had to run ANALYZE at some point in the past. Replaying the WAL sounds like a good idea at the beginning, though. Most journalling filesystems do that too.