<p>I'm building a hobby project with bitcoin-style data storage: I'm going to write block data into one large file. I need to decide how to represent the file in app's memory. Bitcoin uses key-value storage to associate entity hashes with places in data files where they are stored. If I want to do the same, are there any serious performance differences between key-value and relational databases for such a use-case?</p>

CC BY-SA 4.0
2021-03-22T09:50:28.283Z
bitcoin stores the data of blockchain not in a database "key-value", but in raw file data. However, Bitcoin uses the levelbd (and in the last update it could be supported also SQLite) to store the information about the mempool a.k.a chainstate directory.
vincenzopalazzo
CC BY-SA 4.0
2021-03-22T09:53:32.263Z
and maybe this post answer at your question https://bitcoin.stackexchange.com/q/85864/91194
vincenzopalazzo
CC BY-SA 4.0
2021-03-23T08:08:15.840Z
Unfortunately, your link is not enough for me. I will rephrase my question for you: why bitcoin still uses level-db to store the chain-state and not SQLite from the start? Did developers had performance or personal convenience considerations in mind?
Thanks for a fast response.
aikrikunov95
CC BY-SA 4.0
2021-03-23T11:34:56.033Z
I'm not a Bitcoin core developer (unfortunately) but I think that the main motivation is related to history. However, the chain state contains only small information regarding the UTXO and nothings else. All the information is stored on the disk because it is impossible (in my knowledge) to store in a faster way the information in any type of database.
vincenzopalazzo
<storage>
Blockchain data indexing: key-value or relational database?
aikrikunov95
# Blockchain data indexing: key-value or relational database?

(Asked by: username_0 on 2021-03-22)

I'm building a hobby project with bitcoin-style data storage: I'm going to write block data into one large file. I need to decide how to represent the file in app's memory. Bitcoin uses key-value storage to associate entity hashes with places in data files where they are stored. If I want to do the same, are there any serious performance differences between key-value and relational databases for such a use-case?

**Tags:** storage

> **Comments:**
> **username_1**: bitcoin stores the data of blockchain not in a database "key-value", but in raw file data. However, Bitcoin uses the levelbd (and in the last update it could be supported also SQLite) to store the information about the mempool a.k.a chainstate directory.  
> **username_1**: and maybe this post answer at your question https://bitcoin.stackexchange.com/q/85864/91194  
> **username_0**: Unfortunately, your link is not enough for me. I will rephrase my question for you: why bitcoin still uses level-db to store the chain-state and not SQLite from the start? Did developers had performance or personal convenience considerations in mind? Thanks for a fast response.  
> **username_1**: I'm not a Bitcoin core developer (unfortunately) but I think that the main motivation is related to history. However, the chain state contains only small information regarding the UTXO and nothings else. All the information is stored on the disk because it is impossible (in my knowledge) to store in a faster way the information in any type of database.  

---

## 0 answers

