HACKER Q&A
📣 tcsenpai

Which database would you choose for a blockchain?


OK, OK, I said the cursed "B" word. Feel free to mock me for being in the crypto space.

That said, I am in the process of building a blockchain (funded and all, not a hobby project) and I am exploring the various database options.

The only requirements (just lol) are: - Must be completely local - Must be very performant especially in concurrent reads and writes

I am using sqlite3 as a dummy but of course it is not suitable and not scalable enough.

I was wondering if PostgreSQL might be an idea but I am very basic in my knowledge of databases.

In your opinion, given the high throughput and concurrency, where should I start looking?

Bonus points if it is open source of course


  👤 dtagames Accepted Answer ✓
The method of storage isn't a factor in something becoming a blockchain, only the fact that new records contain a hash of previous records, which themselves contain a hash of previous records, and so on. This is the "chain." How you store or retrieve it is up you. Any data storage method you like can be equally "blockchain-y."

👤 MatthiasPortzel
Use sqlite3 until you actually cannot. It sounds like you're assuming it's bad, but it sounds ideal for your use-case since it is designed to be a fully-local database.

👤 tromp
One option is LMDB [1], which is used succesfully in several blockchains.

[1] https://en.wikipedia.org/wiki/Lightning_Memory-Mapped_Data


👤 meiraleal
It is amusing that you got funded while being clueless about what to do. The B word works, after all.

Why are you using a SQL-based database? Blockchain data is so simple you could use Redis.


👤 sfmz
What blockchain attributes are you looking for? ... your local requirement has removed decentralization, distributed-ledger, and transparency.

What's left? immutability?