So I wonder how sq开发者_高级运维lite C/C++ API keeps opened DB: does it use Memory-mapped file? Or how to make it do so?
Yes, it does. Just search sqlite3.c for CreateFileMapping
.
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.
精彩评论