曲径通幽

programming_with_fun();

  C++博客 :: 首页 :: 联系 :: 聚合  :: 管理
  18 Posts :: 0 Stories :: 5 Comments :: 0 Trackbacks

常用链接

留言簿(6)

我参与的团队

搜索

  •  

最新评论

阅读排行榜

评论排行榜

项目里遇到一个问题,在我们程序客户端运行时,sqlite数据库会不断自动生成/删除 journal 文件,高峰时候会占用大量的IO,导致程序很慢。
由于客户端本身的数据完整性不重要,性能非常重要,所以想禁止这个文件的生成。
后来查了一下文档,并实践过后,发现网络上所有的关于关闭/打开某些宏来防止生成的方法都不管用。情急之下,只有改源码了。
改的地方是在main.c 的 sqlite3BtreeFactory 里,直接加个宏就好了 omitJournal

 1 int sqlite3BtreeFactory(
 2   const sqlite3 *db,        /* Main database when opening aux otherwise 0 */
 3   const char *zFilename,    /* Name of the file containing the BTree database */
 4   int omitJournal,          /* if TRUE then do not journal this file */
 5   int nCache,               /* How many pages in the page cache */
 6   int vfsFlags,             /* Flags passed through to vfsOpen */
 7   Btree **ppBtree           /* Pointer to new Btree object written here */
 8 ){
 9   int btFlags = 0;
10   int rc;
11   
12   assert( sqlite3_mutex_held(db->mutex) );
13   assert( ppBtree != 0);
14 
15 #ifdef OMIT_JOURNAL
16   omitJournal = 1; //!< turn off journal file
17 #endif

posted on 2012-01-19 17:58 Meiosis 阅读(482) 评论(0)  编辑 收藏 引用 所属分类: Windows GenericMac OS GenericWork ExperienceLinux Generic

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理