sqlite3性能优化要点

  1. Put inserts/updates in a transaction将插入语句和更新放到一个transaction里
  2. Playing with page sizes makes a difference as well (PRAGMA page_size). Having larger page sizes can make reads and writes go a bit faster as larger pages are held in memory. Note that more memory will be used for your database.调整页大小,较大的页能加快读写速度,但也需要占用更多的内存。
  3. consider calling CREATE INDEX after doing all your inserts.在插入语句后创建索引
  4. concurrent access to SQLite, as the whole database is locked when writes are done, and although multiple readers are possible, writes will be locked out.并发写数据数据库时,数据库锁的问题,高版本已经解决,升级到最新版本3.8.5
  5. Take advantage of saving space...smaller databases go faster. For instance, if you have key value pairs, try making the key an INTEGER PRIMARY KEY if possible, which will replace the implied unique row number column in the table.
  6. If you are using multiple threads, you can try using the shared page cache, which will allow loaded pages to be shared between threads, which can avoid expensive I/O calls.

    Enable Or Disable Shared Pager Cache int sqlite3_enable_shared_cache(int);

转载于:https://www.cnblogs.com/zzzsun/p/3780722.html

你可能感兴趣的:(数据库)