# Nested - Performance - Any other better way?

**URL:** <https://discuss.elastic.co/t/nested-performance-any-other-better-way/160876>\
**Category:** Elasticsearch\
**Created:** [December 14, 2018, 10:23am UTC](https://discuss.elastic.co/t/nested-performance-any-other-better-way/160876 "2018-12-14T10:23:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![boeledi01](https://avatars.discourse-cdn.com/v4/letter/b/94ad74/32.png) [@boeledi01](https://discuss.elastic.co/u/boeledi01)\
**Post date:** [December 14, 2018, 10:23am UTC](https://discuss.elastic.co/t/nested-performance-any-other-better-way/160876/1 "2018-12-14T10:23:00Z")

</div>

Hi All,

I would like to have your opinion and maybe hints on how to improve the way we are indexing the data, from a query performance perspective.

As a foreword, we already tried to flatten as much as possible but we still need to consider "nested" data.

Let me explain (this is a simplified view):

- We have a movement, which contains:

We need to be able to query on anything and to combine anything, such as:

- Look for movements with conditions on movement data, which conditions on gooditems, under which we could also put conditions on gooditems instances. And so forth.

We mapped as follows:

movement

- data
- nested traders
  - data

- nested gooditems
  - data
  - nested traders
    - data

  - nested documents
    - data  
...

This results in generating query statements which involve sometimes lots of "nested".

We need to consider performance and our system counts **billions** of documents.

My fear is on the performance side...

You guys, specialists, could you please tell if this is the correct way to do it or, are there any better ways to do it?

In advance, many thanks

---

<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:** [January 11, 2019, 10:23am UTC](https://discuss.elastic.co/t/nested-performance-any-other-better-way/160876/2 "2019-01-11T10:23:04Z")

</div>

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