17

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

2 Answers 2

5

No, Sqlite will read data for hard disk by paging. The Sqlite document said: "In order to return data from the database to the user, for example as the results of a SELECT query, SQLite must at some point read data from the database file. Usually, data is read from the database file in aligned blocks of page-size bytes. "

Link: https://www.sqlite.org/fileio.html

Sign up to request clarification or add additional context in comments.

Comments

0

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'.

1 Comment

This does not answer original OP question, regarding the internal architecture of sqlite, when the database itself in use, does it first read the whole file into memory? as done when you use a json/ini file, or can it modify parts of the file without first loading it entirely to memory?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.