[英]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?所以我想知道 sqlite C/C++ API 如何保持打开的 DB:它是否使用内存映射文件? Or how to make it do so?
或者如何让它这样做?
Yes, it does.是的,它确实。 Just search sqlite3.c for
CreateFileMapping
.只需搜索 sqlite3.c 的
CreateFileMapping
。
By default, SQLite uses memory mapping for shared memory file which only gets used in WAL journal mode.默认情况下,SQLite 使用 memory 映射共享 memory 文件,该文件仅用于 WAL 日志模式。 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.
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.
但是,如果 SQLite 无法访问 memory 中的 map 文件,则会回退到常规文件 i/o。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.