# How to choose in msgpack, list and map?

**URL:** <https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559>\
**Category:** C# Client\
**Created:** [February 27, 2016, 9:07am UTC](https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559 "2016-02-27T09:07:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![chenjin](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@chenjin](https://discuss.aerospike.com/u/chenjin)\
**Post date:** [February 27, 2016, 9:07am UTC](https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559/1 "2016-02-27T09:07:01Z")

</div>

I have a complex object like this: class myobject{ int id, int level, string desc // max length = 400 }

need to save List as a bin, and i have three choices:

1. json and msgpack
2. store it as Dictionary\<int, List\>, which id as dictionary key, and the value of dictionary is [level, desc]
3. store it as List\<List\>, a list of [id, level, desc]

my question is which one is the best, and why? thank you.

---

<div class="post-metadata">

**Author:** ![manigandham](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/manigandham/32/58_2.png) [@manigandham](https://discuss.aerospike.com/u/manigandham)\
**Post date:** [February 29, 2016, 2:59am UTC](https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559/2 "2016-02-29T02:59:37Z")

</div>

It depends on how you’re going to be accessing the data:

1. Serializing into JSON and storing in a single string bin would be the easiest to deal with. JSON is universal so you can read/write it from any application, however you wont be able to easily manipulate the individual elements within Aerospike (like Lua UDFs).

2. If you need more precise control or want to use Lua code on Aerospike, then you can store the objects using the list and map datatypes. You can use a List bin containing a separate Map for each object. This takes more work in translating your object but you can then your own logic in the database to query and manipulate the data without your application involved.

---

<div class="post-metadata">

**Author:** ![chenjin](https://avatars.discourse-cdn.com/v4/letter/c/57b2e6/32.png) [@chenjin](https://discuss.aerospike.com/u/chenjin)\
**Post date:** [February 29, 2016, 9:37am UTC](https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559/3 "2016-02-29T09:37:07Z")

</div>

thank you. its very helpful. can you tell me more how about the performance differences?

---

<div class="post-metadata">

**Author:** ![manigandham](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.aerospike.com/manigandham/32/58_2.png) [@manigandham](https://discuss.aerospike.com/u/manigandham)\
**Post date:** [February 29, 2016, 9:57am UTC](https://discuss.aerospike.com/t/how-to-choose-in-msgpack-list-and-map/2559/4 "2016-02-29T09:57:00Z")

</div>

There’s not much difference here, at least with Aerospike. The database just stores whatever you send it.

Choose the format that gives you the functionality you want first because there probably isn’t any real performance impact. JSON might be a little faster to serialize into a string than building out the list and map but you will have to test and see what the impact is.
