[英]Change journal_mode on SQLite with TCL
I want to upgrade my inserts velocity and I read about modifying the journal mode.我想升级我的插入速度并且我阅读了有关修改日志模式的信息。 How can I do it on TCL code?
我怎样才能在 TCL 代码上做到这一点? Thanks!
谢谢!
Assuming db
is your SQLite database handle, you just issue a PRAGMA
like this:假设
db
是您的 SQLite 数据库句柄,您只需像这样发出PRAGMA
:
db eval {
PRAGMA journal_mode = WAL;
}
If you care a lot about speed and not much about integrity (I have one application where this is the case) then you're probably sufficiently well served by just turning off synchronization while you're doing all the inserts.如果您非常关心速度而不是完整性(我有一个应用程序就是这种情况),那么您在执行所有插入操作时只需关闭同步就可以得到足够好的服务。
db eval {
PRAGMA synchronous = OFF;
}
Doing this makes writing to an SQLite database about as fast as just writing directly to your own binary file, but it is only a good idea in some cases.这样做使得写入 SQLite 数据库的速度与直接写入您自己的二进制文件一样快,但在某些情况下这只是一个好主意。 (My case alluded to above is where the writing process is what made the database and where anything other than total success is not useful to users. It's definitely not a normal database use-case!)
(上面提到的我的案例是编写过程是数据库的组成部分,除了完全成功之外,其他任何事情对用户都没有用。这绝对不是正常的数据库用例!)
Note that pragmas are per DB handle/connection.请注意,pragma 是针对每个 DB 句柄/连接的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.