Chin
Chin

Reputation: 20675

Load entire SQLite database into RAM to improve performance

I have a large SQLite database for my application (around 100MB). This database is read only and never written into. The performance of working with the database is decent, since I made sure that most of the queries have indexes backing them up. However I would like to speed it up further by caching the entire database into RAM to avoid disk access.

Is this possible and if so how can I do it?

Upvotes: 0

Views: 1480

Answers (1)

CL.
CL.

Reputation: 180020

A database file is a file, so you can just read it to put it into the OS's file cache. (And if the OS decides to throw the data out again, then it might have a reason for it …)

For an on-disk database, SQLite needs to check if some other process has made changes. To avoid that, you can use PRAGMA locking_mode = EXCLUSIVE. However, the difference probably isn't measurable.

Upvotes: 1

Related Questions