to improve sqlite performance
INSERT is really slow - I can only do few dozen INSERTs per second
http://www.sqlite.org/faq.html#q19
Actually, SQLite will easily do 50,000 or more INSERT statements per second on an average desktop computer. But it will only do a few dozen transactions per second. Transaction speed is limited by the rotational speed of your disk drive. A transaction normally requires two complete rotations of the disk platter, which on a 7200RPM disk drive limits you to about 60 transactions per second.
Transaction speed is limited by disk drive speed because (by default) SQLite actually waits until the data really is safely stored on the disk surface before the transaction is complete. That way, if you suddenly lose power or if your OS crashes, your data is still safe. For details, read about atomic commit in SQLite..
By default, each INSERT statement is its own transaction. But if you surround multiple INSERT statements with BEGIN...COMMIT then all the inserts are grouped into a single transaction. The time needed to commit the transaction is amortized over all the enclosed insert statements and so the time per insert statement is greatly reduced.
Another option is to run PRAGMA synchronous=OFF. This command will cause SQLite to not wait on data to reach the disk surface, which will make write operations appear to be much faster. But if you lose power in the middle of a transaction, your database file might go corrupt.
http://blogs.msdn.com/b/andy_wigley/archive/2013/11/21/how-to-massively-improve-sqlite-performance-using-sqlwinrt.aspx
http://blog.quibb.org/2010/08/fast-bulk-inserts-into-sqlite/
http://www.codeproject.com/Articles/853842/Csharp-Avoiding-Performance-Issues-with-Inserts-in
http://stackoverflow.com/questions/1711631/improve-insert-per-second-performance-of-sqlite
threadsafe / sqlite in multithread
https://www.sqlite.org/threadsafe.html
I read everywhere that creating transactions is the solution to slow SQLite writes, but it can be long and painful to rewrite your code and wrap all your SQLite writes in transactions.
I found a much simpler, safe and very efficient method: I enable a (disabled by default) SQLite 3.7.0 optimisation : the Write-Ahead-Log (WAL). The documentation says it works in all unix (i.e. Linux and OSX) and Windows systems.
How ? Just run the following commands after initializing your SQLite connection:
PRAGMA journal_mode = WAL
PRAGMA synchronous = NORMAL
My code now runs ~600% faster : my test suite now runs in 38 seconds instead of 4 minutes :)
to improve sqlite performance的更多相关文章
- Five Invaluable Techniques to Improve Regex Performance
Regular expressions are powerful, but with great power comes great responsibility. Because of the wa ...
- Ten ways to improve the performance of large tables in MySQL--转载
原文地址:http://www.tocker.ca/2013/10/24/improving-the-performance-of-large-tables-in-mysql.html Today I ...
- build a real-time analytics dashboard to visualize the number of orders getting shipped every minute to improve the performance of their logistics for an e-commerce portal
https://cloudxlab.com/blog/real-time-analytics-dashboard-with-apache-spark-kafka/
- [XAF] How to improve the application's performance
[自己的解决方案]数据量大时,可显著提升用户使用体验! 1.Root ListView 参考官方的E1554 点击导航菜单后首先跳出查询条件设置窗体进行设置 可设置查询方案或查询方案的查询条件,排序字 ...
- (转) Ensemble Methods for Deep Learning Neural Networks to Reduce Variance and Improve Performance
Ensemble Methods for Deep Learning Neural Networks to Reduce Variance and Improve Performance 2018-1 ...
- [转]How to Improve Entity Framework Add Performance?
本文转自:http://entityframework.net/improve-ef-add-performance When you overuse the Add() method for mul ...
- How To Improve Deep Learning Performance
如何提高深度学习性能 20 Tips, Tricks and Techniques That You Can Use ToFight Overfitting and Get Better Genera ...
- WPF Freezable–How to improve your application's performances
在给ImageBrush绑定动态图片是会报以下错误. Error 4 The provided DependencyObject is not a context for this Fre ...
- How to Configure Nginx for Optimized Performance
Features Pricing Add-ons Resources | Log in Sign up Guides & Tutorials Web Server Guides Nginx ...
随机推荐
- sqlserver 统计信息自动更新 ----trace flag 2371
对于已经应用的表(非临时表)统计信息更新条件为500+20%,具体更新条件 If the statistics is defined on a regular table, it is out of ...
- python及pandas,numpy等知识点技巧点学习笔记
python和java,.net,php web平台交互最好使用web通信方式,不要使用Jypython,IronPython,这样的好处是能够保持程序模块化,解耦性好 python允许使用'''.. ...
- selenium模拟鼠标操作
Selenium提供了一个类ActionChains来处理模拟鼠标事件,如单击.双击.拖动等. 基本语法: class ActionChains(object): """ ...
- CentOS随笔 - 5.CentOS7安装Sql Server 2017
前言 转帖请注明出处: http://www.cnblogs.com/Troy-Lv5/ 开发环境嘛, 作为.Net系Sql Server那是必备的. 听过Sql server可以安装在Linux上了 ...
- MyEclipse 智能提示设置
在实际的开发当中,编译器没有智能提示,确实是效率很低,下面我就给大家讲一下在MyEclipse中设置智能提示,方便大家的开发,希望能帮到大家. 方法一:首先,在MyEclipse的菜单栏中找到wind ...
- python常见释疑(有别于报错)(不定时更新)
文:铁乐与猫 01.在cmd运行py脚本后,直接回到了提示符,没有任何输出,看起来像是并没有运行一样. 答:你的感觉很可能是对的,但脚本很可能己经正常运行,只是你的代码里面很可能没有给出print提示 ...
- Entity Framework的基本操作
一.使用基本的方法进行增删改查 二.使用状态进行增删改查,即使用基类对象进行操作 三.多个表同时进行添加 添加数据后获取自动增长 ...
- win8中 cmd直接以管理员权限运行
一.组合键 WIN+X 二.锁定到任务栏,方便以后快速启动 三.控制面板->控制中心 四.更改用户账户控制设置--调到最低 好了,点击任务栏的命令提示符
- reactor模型框架图和流程图 libevent
学习libevent有助于提升程序设计功力,除了网络程序设计方面外,libevent的代码里有很多有用的设计技巧和基础数据结构,比如信息隐藏.函数指针.c语言的多态支持.链表和堆等等,都有助于提升自身 ...
- 安装mysql中遇到的问题1
我的debian7之前安装了mysql-server,是通过apt安装的,后来我卸载掉, 然后用whereis mysql查找, 把所有关于mysql的目录删除掉,包括带mysqld的目录及文件. 重 ...