# Poor Query Performance using nested document structure

**URL:** <https://discuss.elastic.co/t/poor-query-performance-using-nested-document-structure/130781>\
**Category:** Elasticsearch\
**Created:** [May 7, 2018, 6:23am UTC](https://discuss.elastic.co/t/poor-query-performance-using-nested-document-structure/130781 "2018-05-07T06:23:48Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [May 7, 2018, 8:20am UTC](https://discuss.elastic.co/t/poor-query-performance-using-nested-document-structure/130781/7 "2018-05-07T08:20:23Z")

</div>

So you have a lot of nested docs here which is causing lot of internal "joins" at search time.  
Few things I can think about:

- First once the segments are loaded in memory (if you have enough memory left for the OS FS Cache), hopefully this will be much faster.
- May be having more shards in that case with fewer documents per shard would help to reduce that time
- Depending on your use case, don't use nested when not absolutely necessary.

But may be @jpountz has other ideas?

---

_[View the full topic](https://discuss.elastic.co/t/poor-query-performance-using-nested-document-structure/130781)._
