SQLite - Optimize read-only database

By xngo on January 2, 2020

  1. Compact the database by using VACUUM command to defragment data. It will reduce time to access data since they are close together.
  2. Since data don't change, then set journaling switch off: PRAGMA journal_mode=OFF.
  3. Open SQLite database connection in read-only mode, SQLITE_OPEN_READONLY.

About the author

Xuan Ngo is the founder of OpenWritings.net. He currently lives in Montreal, Canada. He loves to write about programming and open source subjects.