Does SQLite load whole db file into memory when connected?

前端 未结 2 1514
耶瑟儿~
耶瑟儿~ 2021-02-19 19:18

I want to know is Database more efficient or just a normal json file if it has many items, in android device.

2条回答
  •  醉酒成梦
    2021-02-19 19:58

    There is an option when "connecting" to an SQLite database of using memory instead of filesystem as storage.

    But it is used only when creating new databases so the "new" in memory database will be empty. This is useful when you want to take advantage of SQL like indexing and querying on a large set of data.

    Unfortunately copy from filesystem into memory (or vice-versa) is not a feature in SQLite. It's a design choice because the SQLite file must be locked by your (or others) for concurrency control.

    Typically a DSN to connect to an SQLite database would look like this 'sqlite:/path/to/file.sqlite'. And access control to the database is given by access filesystem rights. In the case of in memory databases the DSN will look like this 'sqlite::memory'.

提交回复
热议问题