# Best practice with defining multiindex

**URL:** <https://discuss.elastic.co/t/best-practice-with-defining-multiindex/41982>\
**Category:** Elasticsearch\
**Created:** [February 17, 2016, 7:38am UTC](https://discuss.elastic.co/t/best-practice-with-defining-multiindex/41982 "2016-02-17T07:38:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Grigory\_Rubstein](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/grigory_rubstein/32/793_2.png) [@Grigory\_Rubstein](https://discuss.elastic.co/u/Grigory_Rubstein)\
**Post date:** [February 17, 2016, 7:38am UTC](https://discuss.elastic.co/t/best-practice-with-defining-multiindex/41982/1 "2016-02-17T07:38:38Z")

</div>

I store data for one year ,  
the data is time and account based, while every possible query always referred to one account only.

what will better for query performance , separate all data to time based (month) index , or create multi index based on account number (for example modulo 100 on account number)

the data is  
400M docs per month  
about 100,000 accounts.  
not all account equals by number of documents.  
query can be done only on one account but on every possible date of the year.

Thank you.

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [February 17, 2016, 1:18pm UTC](https://discuss.elastic.co/t/best-practice-with-defining-multiindex/41982/2 "2016-02-17T13:18:13Z")

</div>

Having time-based indices allow you to manage retention period efficiently, and is the recommended way of handling retention whenever possible. You can however combine this with [routing](https://www.elastic.co/guide/en/elasticsearch/reference/2.2/docs-index_.html#index-routing) based on the account ID at indexing and query time. This ensures that all records belonging to a single account are sent to the same shard (you do not control which one) and this allows queries to hit just one shard per month instead of all. Whether adding this extra complexity is beneficial or not will depend on your data volumes. I would recommend starting without routing and only enable it if needed.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:15pm UTC](https://discuss.elastic.co/t/best-practice-with-defining-multiindex/41982/3 "2017-07-05T23:15:44Z")

</div>


