bhvn
bhvn

Reputation: 92

Internal architecture of in memory data base

I'm using SQLite open-source database in my embedded system.
I have set below PRAGMA

qDb.exec("PRAGMA synchronous = OFF");
qDb.exec("PRAGMA journal_mode = MEMORY");

PRAGMA is for In-Memory working. Without this flag database performance is slow but after this PRAGMA performance improvement is really noticeable.

so I decide to use an in-memory database for my embedded application. I know that the in-memory database whole dataset in RAM whereas in the traditional database whole database in DISK. So RAM operation is faster then DISK operation.

My question

  1. I want to understand when data is written in the main memory? (Let's say I have written 100 rows in table A. After which time it is safe to the power of the device)

  2. How to minimize data loss risk in an in-memory database. (Is it technically possible)

Correct me if my understanding is wrong.

Thank you for reading.

Upvotes: 1

Views: 98

Answers (1)

user3559721
user3559721

Reputation: 134

SQLite has a checkpoint that is managed data to write data in the main memory.

An automatic checkpoint is taken when the transaction log file becomes bigger than X GB since the last checkpoint. And after that size of the transaction log data write-in to main memory from RAM.

Data also write in the main memory when the last database connection on a database file closes.

Upvotes: 1

Related Questions