-
A common optimization for WAL-mode databases is setting PRAGMA synchronous=NORMAL, trading off some power-loss durability for ~50x more write throughput. It's a per connection setting, so it has to be set for individual connection in the pool, with something like: conns := []*sqlite.Conn{}
for range poolsize {
conn, _ := pool.Take(context.Background())
conns = append(conns, conn)
sqlitex.ExecuteTransient(conn, `PRAGMA synchronous=NORMAL`, nil)
}
for _, conn := range conns {
pool.Put(conn)
} Or, shorter but depending on Pool being implemented with a buffered channel: for range poolsize {
conn, _ := pool.Take(context.Background())
sqlitex.ExecuteTransient(conn, `PRAGMA synchronous=NORMAL`, nil)
pool.Put(conn)
} There are other optimization pragmas that might be desired too, like Perhaps this could be wrapped in a helper function like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
This sort of every-connection setup is what |
Beta Was this translation helpful? Give feedback.
This sort of every-connection setup is what
PrepareConn
is for. Does that work for your use case?