How to limit database upload to disk?

I use sqlite database in my embedded arm9 Linux platform. I want to reduce writing to the disk database because my disk is flash memory and it needs minimal write cycles. So I tried to increase SQLITE_DEFAULT_CACHE_SIZE to 5000. My goal was to write data to the cache and when the cache is full, it is automatically flushed to disk. But by increasing SQLITE_DEFAULT_CACHE_SIZE, I cannot confirm whether this works or not. I do not see any changes in operations! Am I right? Can someone give me some suggestions? thanks Aneesh

+5
source share
4 answers

The latest SQLite has a backup function for hot databases , it is still experimental, but I would recommend using a memory database and combine it with the disk database if you think it is necessary.

+2
source

SQLite is an ACID db flushes with every commit OR with every insert / delete / update, not completed transaction. Use transactions for grouping operations OR DISABLE ACIDity and set PRAGMA synchronous = OFF.

"PRAGMA synchronous = OFF" and SQLite will not completely clear the data (actually leaving this for the OS cache)

SQLITE_DEFAULT_CACHE_SIZE ONLY for cache size. And the cache is used ONLY for reading data.

- VFS , . http://www.sqlite.org/c3ref/vfs.html

, sync = off ( ) ( db reset = ).

- . - , .

+2

Ok Neil. If "SQLite uses a write caching form", then when the cache overflows, it will try to clear the data to some temporary file or disk file. This is the same moment that I am trying to experiment with the size of the cache and thus gain control over the speed of cleaning. But this does not happen. Give an answer.

0
source

You have SQLite source code - why not just use the tool to record the information you are interested in.

-1
source

All Articles