Why is the Bitcoin Core wallet moving from Berkeley DB to SQLite for its database backend?
The introduction of descriptor wallets presents an opportunity to introduce a new database backend as descriptor wallets are backwards incompatible. The following is taken from Andrew Chow's blog post on what's coming to the Bitcoin Core wallet in 0.21. (There was also discussion on this GitHub Issue.)
Why move from Berkeley DB?
- Not designed to be used as an application data file. The Legacy Wallet has several hacks to get round this as a result and Berkeley DB wallet files can easily be corrupted.
- Berkeley DB produces extra files which need to be moved with the database file. This means that Berkeley DB is less portable and requires a directory for each wallet.
- Changes were introduced to Berkeley DB database environment files breaking backwards compatibility.
Why choose SQLite?
Can be used as an application data file.
New SQLite versions maintains backwards compatibility with versions as far back as 2013.
Does not require database environment. A completed write guarantees that the data was written to the database file.
Can now move to single wallet files instead of wallet directories.
Here is the proposed timeline for legacy wallet and Berkeley DB removal from Bitcoin Core.