# Go-ds-flatfs vs go-ds-leveldb

**URL:** <https://discuss.ipfs.tech/t/go-ds-flatfs-vs-go-ds-leveldb/9858>\
**Category:** Uncategorized\
**Created:** [January 16, 2021, 9:12am UTC](https://discuss.ipfs.tech/t/go-ds-flatfs-vs-go-ds-leveldb/9858 "2021-01-16T09:12:30Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![krishraghuram](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/krishraghuram/32/4335_2.png) [@krishraghuram](https://discuss.ipfs.tech/u/krishraghuram)\
**Post date:** [January 16, 2021, 9:12am UTC](https://discuss.ipfs.tech/t/go-ds-flatfs-vs-go-ds-leveldb/9858/1 "2021-01-16T09:12:30Z")

</div>

I understand that there is some connection/relation between these two, but I’m not sure how they are connected/related.

My initial understanding was that the metadata of “what blocks are locally available” is stored in the leveldb inside `$IPFS_PATH/datastore`, and the actual block data is stored in the `$IPFS_PATH/blocks`.

But, after digging around a bit, I noticed two things,  
1 - [Blockstore uses prefix `"blocks"`](https://github.com/ipfs/go-ipfs-blockstore/blob/7adc396ab4b40c660c72d215b3a58999b6f63413/blockstore.go#L24)  
2 - After adding a bunch of files to my IPFS, I looked at the keys in the leveldb, and could not find a single key containing `"blocks"` prefix. I could only see `/pins` and `/providers`

This leads me to think that, in the default profile, both the leveldb and flatfs datastores are used - leveldb for metadata like pins, provider records etc. and flatfs for actually storing the blocks. And the leveldb does not contain ANY data/metadata about what is stored in the flatfs datastore.

---

<div class="post-metadata">

**Author:** ![krishraghuram](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/krishraghuram/32/4335_2.png) [@krishraghuram](https://discuss.ipfs.tech/u/krishraghuram)\
**Post date:** [January 16, 2021, 9:15am UTC](https://discuss.ipfs.tech/t/go-ds-flatfs-vs-go-ds-leveldb/9858/2 "2021-01-16T09:15:22Z")

</div>

(Apologies for the poor way in which I asked the above question)

Here is what I understand about flatfs and leveldb datastores now. Please correct me if any part of below statements are wrong.

- [go-ds-flatfs](https://github.com/ipfs/go-ds-flatfs) is a datastore implementation that is used only to store blocks. The data is actually stored as files in the filesystem, specifically in the `$IPFS_PATH/blocks` folder.
- [go-ds-leveldb](https://github.com/ipfs/go-ds-leveldb) is a datastore implementation that uses leveldb to store everything (like pins, provider records) except blocks. It does not store any data/metadate about the blocks at all. The data is stored as leveldb key value pairs. The leveldb location is `$IPFS_PATH/datastore`.

Thank you 🙂

---

<div class="post-metadata">

**Author:** ![stebalien](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ipfs.tech/stebalien/32/156_2.png) [@stebalien](https://discuss.ipfs.tech/u/stebalien)\
**Post date:** [January 17, 2021, 5:19pm UTC](https://discuss.ipfs.tech/t/go-ds-flatfs-vs-go-ds-leveldb/9858/3 "2021-01-17T17:19:16Z")

</div>

Your understanding is mostly correct.

Really, they’re just two different datastores:

- go-ds-flatfs is a very simple flat-file datastore that can _only_  
store blocks and doesn’t really implement all the features we expect  
datastores to implement (e.g., sorted queries, etc.).
- go-ds-leveldb is a general-purpose datastore that can store  
anything. However, it doesn’t perform very well when storing large  
blobs of data (e.g., blocks).

By default, go-ipfs uses flatfs for blocks, and leveldb for everything  
else. You can also replace one or both with go-ds-badger or mix and  
match by “mounting” datastores on top of each other.
