Closed brentongunning closed 3 years ago
Fixed in https://github.com/runonbitcoin/run-db/commit/5bad5d3067f3b02d111c979ab5db2437807f772c
Result: Size reduction from 2.8G to 1.9G, ~33%.
Note that the VACUUM command during the upgrade takes ~5 minutes to complete for the size above on a regular laptop.
If you are querying hex strings from the tx table, you just need to change:
SELECT hex FROM tx WHERE ...
to
SELECT HEX(bytes) AS hex FROM tx WHERE ...
sqlite3_analyzer
reports that thetx
table is ~59% of the database right now, and thehex
column in that table is the bulk of it. We should convert that to the BLOB data type. TheHEX()
function of sqlite can be used to convert back to hex quickly in queries so changing this table should require minimal run-db changes. I'd also like to version the database so that existing DBs can be upgraded upon restart. After hex, other savings could be the txid, deps, spends, and location columns, but changing these will custom queries more difficult. Converting just the hex column will shrink the database by ~30% if using the default trustlist.