transaction除了保证完整性还能加速
来源:互联网 发布:三拼音域名 编辑:程序博客网 时间:2024/04/29 23:37
As described in my previous notes, SQLite, by default, creates a journal file for each transaction, and delete the file after the transaction completes. The above code does not explicitly create any transactions, so each insert call will be treated as an independent one. As a result, expansive file operations will be called frequently and slow down the process...
Therefore, I modified the code to make all the insert calls in the same batch in a single transaction:
I then tested the code in the emulator running on my notebook. The original code inserts at a rate of around 10 records per second, while the version with transaction inserts at a rate of 30+ records per seconds. WOW, that's a sound improvement!
Therefore, I modified the code to make all the insert calls in the same batch in a single transaction:
try{ db.beginTransaction(); for each record in the list { do_some_processing(); if (line represent a valid entry) { db.insert(SOME_TABLE, null, SOME_VALUE); } some_other_processing(); } db.setTransactionSuccessful();} catch (SQLException e) {} finally { db.endTranscation();}
I then tested the code in the emulator running on my notebook. The original code inserts at a rate of around 10 records per second, while the version with transaction inserts at a rate of 30+ records per seconds. WOW, that's a sound improvement!
- transaction除了保证完整性还能加速
- 如何保证transaction commit的完整性
- 人工智能除了下围棋还能干啥?
- 除了航拍,无人机还能检测鲨鱼
- 怎么花钱能变得富有,除了读书还能这样
- 微软除了黑屏还能怎么操纵我们的PC
- 中国资金除了中国股市还能投资啥?
- 北大除了“啃老”还能“啃”什么
- 在程序员联盟除了编程,你还能学到这些
- 除了升级tomcat版本外,还能怎么解决?
- 面对勒索软件,除了交赎金,还能怎么办?
- 选offer,除了钱,还能比这些!
- 吸管除了喝饮料还能干嘛?做机器人呀~
- 社交软件除了“约“还能如何”玩“?
- 3.保证数据完整性
- 如何保证数据库完整性
- 约束-保证数据完整性
- MySql_保证数据完整性
- 出来一周了。
- 关于!$assertionsDisabled
- 430调试经验小谈
- android debug工具集
- struts2 设置select选中
- transaction除了保证完整性还能加速
- android 重写adpter
- android out of memory oom问题
- http_referer是什么
- 设计模式
- 数据结构:线性表(顺序存储)顺序表类(实现顺序表的创建,输出,插入,删除功能)
- 并行实现
- Connection对象
- Emacs org-mode helloworld实验