SQLite Forum

How much would you trust a page-level checksum ?
Login
i've been using a version of SQLite with the checksum VFS recently

<https://www.sqlite.org/cksumvfs.html>

and have been musing: how much would I trust a checksum ?

SQLite goes to some lengths to avoid writing data which hasn't changed.  It does this on a row-by-row basis, and that involves extra processing.  And the processing doesn't catch every possibliity: the checks are performed only under certain circumstances.  But the checksum VFS would allow SQLite to detect, at the page level, whether it's necessary to rewrite a page.

There are advantages for this: most databases have more than one row per page, so I *think* less processing would be required.  Both tables and indexes are stored in pages, and this technique would allow SQLite to notice when a table page needed an update, but the index page did not.  Or /vice versa/.  But I don't know enough about how SQLite works internally to evaluate this.  Or to know whether it would be necessary or convenient to read the checksum of a page being replaced.  I'd appreciate comments.

And the most important thing: given the size of the checksum used, what's the risk that a change in a page's contents would leave the checksum unchanged ?