SQLite Forum

memory vs mmap
Login
I was surprised to find that the ":memory:"
option of Sqlite is twice as fast than a
named file with a large pragma mmap so that
mmap() is used.

Everything should be completely in memory
either way, so it comes down to Sqlite call
overhead.

The ":memory:" database is populated using a
"restore from" to copy the disk file into
memory.

I would like the large read-only database to
be shared by multiple processes.

The main application is in Java and using
sqlite-jdbc.

The documentation says that in-memory databases
can only be shared by a single process:

https://www.sqlite.org/inmemorydb.html

What is the reason for that restriction, and
what is the technical reason that in-memory
is so much faster than mmap? And is there
any alternative to get closer to in-memory
performance while having the database shared
by multiple processes?

Thanks. Paul.