Comment by tejinderss
Comment by tejinderss 2 days ago
Do you know any good default PRAGMAs that one should enable?
Comment by tejinderss 2 days ago
Do you know any good default PRAGMAs that one should enable?
You should pragna optimize before TX end, not at tx start.
Except for long lived connections where you do it periodically.
https://www.sqlite.org/lang_analyze.html#periodically_run_pr...
Yes, if journal_mode was not sticky, a new process opening the db would not know to look for the wal and shm files and read the unflushed latest data from there. On the other hand, foreign key enforcement has nothing to do with the file itself, it's a transaction level thing.
In any case, there is no harm in setting sticky pragmas every connection.
Explanation of sqlite performance PRAGMAs
Although not what you asked for, the SQLite authors maintain a list of recommended compilation options that should be used where applicable.
https://sqlite.org/compile.html#recommended_compile_time_opt...
These are my PRAGMAs and not your PRAGMAs. Be very careful about blindly copying something that may or may not match your needs.
Note that I do not use auto_vacuum for DELETEs are uncommon in my workflows and I am fine with the trade-off and if I do need it I can always PRAGMA it.defer_foreign_keys is useful if you understand the pros and cons of enabling it.