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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值