Home > Software design >  Change journal_mode on SQLite with TCL
Change journal_mode on SQLite with TCL

Time:10-02

I want to upgrade my inserts velocity and I read about modifying the journal mode. How can I do it on TCL code? Thanks!

CodePudding user response:

Assuming db is your SQLite database handle, you just issue a PRAGMA like this:

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. (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.

  • Related