databasesqlitesd-carddisk-access

SQLite: will it write to disk when updating same data?


A client application receives a table from server and stores it in local SQLite database. The table is sent frequently but changes rarely, so most updates insert into local database data that is already there.

Will SQLite do disk writes after such updates? Data is stored on SD card and writing to it frequently is a bad idea.

I can read the data from the database compare with received table and update only the rows that have changed. Maybe SQLite is smart and will do this for me transparently?


Solution

  • When you run a statement like this:

    UPDATE SomeTable SET ... WHERE ...
    

    then all rows that are matched by the WHERE clause get rewritten.

    If you want to avoid that, you have to compare the row values yourself.