Last active
April 22, 2019 10:09
-
-
Save gastonfeng/21b92b2cad1f71d595d3f41b92560847 to your computer and use it in GitHub Desktop.
SQLite
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQLite写是锁整个数据库的,在写着数据库的时候,不能进行其它操作,同时读没有问题。 | |
Sqlite 插入速度慢,平均插入一条速度在110ms左右,所以需要优化: | |
法1) | |
//提升读写速度 | |
m_database.exec("PRAGMA synchronous = OFF"); | |
m_database.exec("PRAGMA journal_mode = MEMORY"); | |
1 | |
2 | |
3 | |
法2) | |
手动开启事务,多条日志同时提交,如子线程代码所示。 | |
bool ok = query.exec("begin"); | |
while (logList.size() > 0) { | |
插入日志 ... | |
} | |
ok = query.exec("commit"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment