# Map in a single bin VS one bin per key of map

**URL:** <https://discuss.aerospike.com/t/map-in-a-single-bin-vs-one-bin-per-key-of-map/1087>\
**Category:** Data Types\
**Created:** [March 23, 2015, 11:29am UTC](https://discuss.aerospike.com/t/map-in-a-single-bin-vs-one-bin-per-key-of-map/1087 "2015-03-23T11:29:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ashishbhutani](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/ashishbhutani/32/183_2.png) [@ashishbhutani](https://discuss.aerospike.com/u/ashishbhutani)\
**Post date:** [March 23, 2015, 11:29am UTC](https://discuss.aerospike.com/t/map-in-a-single-bin-vs-one-bin-per-key-of-map/1087/1 "2015-03-23T11:29:12Z")

</div>

Hi

I am new to Aerospike and trying to use it my project. I have my data in a map, like this:

item1 =\> {key1 =\> val1, key2 =\> val2}

item2 =\> {key1 =\> val3, key2 =\> val4}

item3 =\> {key1 =\> val5, key2 =\> val6, key3 =\>val7}

Here item1/item2/item3 are my keys. Values stored against them are further key value pairs.

So, I have two options I guess.

One way is to create separate bin for ‘key1’/‘key2’/‘key3’.

Second way is to create just a single bin, say ‘mybin’ and store entire value for item1/item2/item3 in that as a map.

My app will be always fetching the entire value of each item.

Also, I will be mostly using flash persistence.

I want my app to be read optimized. Which of these two approaches is better ? Please suggest.

---

<div class="post-metadata">

**Author:** ![wchu](https://avatars.discourse-cdn.com/v4/letter/w/a5b964/32.png) [@wchu](https://discuss.aerospike.com/u/wchu)\
**Post date:** [April 24, 2015, 10:32pm UTC](https://discuss.aerospike.com/t/map-in-a-single-bin-vs-one-bin-per-key-of-map/1087/2 "2015-04-24T22:32:58Z")

</div>

If you want to only read a few items of the map each time, then it would make sense to keep the entries in separate bins. Please note though, that Aerospike has a limitation of # of unique bin-names for a namespace, of 32k. (See [https://www.aerospike.com/docs/guide/FAQ.html](https://www.aerospike.com/docs/guide/FAQ.html))

If the items can be varying, and you’d want to read all the data back all the time, then it may make more sense to have a map.

In either case though, the full record will be read from the SSD each time for a read request.
