# Good practice in distributing data in indexes

**URL:** <https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835>\
**Category:** Elasticsearch\
**Created:** [June 14, 2019, 10:43am UTC](https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835 "2019-06-14T10:43:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathias\_Muntz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias_muntz/32/48144_2.png) [@Mathias\_Muntz](https://discuss.elastic.co/u/Mathias_Muntz)\
**Post date:** [June 14, 2019, 10:43am UTC](https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835/1 "2019-06-14T10:43:31Z")

</div>

Hello everyone,

Here is a small description of the situtation.

We have approximately 5,000 customers who use a tool connected to a Postgres database. Each client can manipulate the data in a database of its own. Each database contains approximately 30 tables. The model of each base is identical. So we have this:

db\_customer\_1

- table\_1
- table2
- ...
- table\_30  
...  
db\_customer\_5000
- table\_1
- ...

We would like to index all this data in Elasticsearch. But we can not choose how to create our indexes.

First proposal:  
We put all the data of the table\_1 of each database in an index called index\_table\_1, with an identifier on the document allowing to know the customer. About 30 indexes.

Second solution:  
We put the data for each table\_1 for each customer in a single index called index\_customer\_1\_table\_1. At present, approximately 150000 indexes.

We are afraid that the first solution will cause performance issues because the data, even if based on the same model, does not belong to the same client.

We are afraid with the second solution, because the increase in the number of indexes can be a problem in the medium term.

Can you help us ?

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:** [June 14, 2019, 12:20pm UTC](https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835/2 "2019-06-14T12:20:03Z")

</div>

The number of indices in option 2 will be an immediate problem so I would recommend option 1.

---

<div class="post-metadata">

**Author:** ![Mathias\_Muntz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mathias_muntz/32/48144_2.png) [@Mathias\_Muntz](https://discuss.elastic.co/u/Mathias_Muntz)\
**Post date:** [June 14, 2019, 12:48pm UTC](https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835/3 "2019-06-14T12:48:07Z")

</div>

Thank you for your reply.  
Is there a way a specific mapping or something else that I can put on the field customer\_id of my document? Like Indexe in DBMS. To allow my aggregation to be as efficient as possible? Because they will always start with match:{customer\_id:\*\*\*\*,....}

---

<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 12, 2019, 12:48pm UTC](https://discuss.elastic.co/t/good-practice-in-distributing-data-in-indexes/185835/4 "2019-07-12T12:48:10Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
