Rella
Rella

Reputation: 66945

Does sqlite C\C++ library keep DB file as Memory-mapped file? and is it possible to make it do so?

So I wonder how sqlite C/C++ API keeps opened DB: does it use Memory-mapped file? Or how to make it do so?

Upvotes: 0

Views: 2272

Answers (2)

user1669844
user1669844

Reputation: 763

By default, SQLite uses memory mapping for shared memory file which only gets used in WAL journal mode. As per SQLite documentation https://sqlite.org/mmap.html, we can set PRAGMA mmap_size to force SQLite to use memory mapped file i/o in other modes as well. However, SQLite falls back to regular file i/o if it fails to map files in the memory.

Upvotes: 0

Don Reba
Don Reba

Reputation: 14051

Yes, it does. Just search sqlite3.c for CreateFileMapping.

Upvotes: 2

Related Questions