go-sqlite3 icon indicating copy to clipboard operation
go-sqlite3 copied to clipboard

[REQUEST] Memory with writeback

Open the-hotmann opened this issue 3 years ago • 2 comments

For performance reasons I would like to ask, if this is possible?

Opening an existing SQLite3 file and writing it into Memory. But everytime I write or read everything, I would like it to happen in memory (so way quicker). But after it is written an async task should write it back.

Currently I have tried it likle this:

db, err = sql.Open("sqlite3", "file:../data/tickets.db?mode=memory&cache=shared&_journal_mode=MEMORY")

But everytime I read/write it is way slower then other SQLite3 implementations - like in GORM, Python3 ... Here a write and read takes about 1,5ms, but for these others it actually is about 0,05ms which for me is a big difference.

So I would like to know what I migh be doing wrong., Are any of these settings (mode=memory&cache=shared&_journal_mode=MEMORY) not beneficial for performance? Even when I have the mode=memory set, it does not seem to be actually as fast as it should be if it would have been in memory. And it does not work, when I want it to load a DB from SSD into memory. I already have a DB, and this should be copied over into memory - I dont want to have a fresh DB everytime, as this is what is happening as soon as I use mode=memory.

Would be happy to get any feedback and I am open for an discussion.

the-hotmann avatar Dec 20 '22 23:12 the-hotmann