# Nested Document performance

**URL:** <https://discuss.elastic.co/t/nested-document-performance/9821>\
**Category:** Elasticsearch\
**Created:** [November 26, 2012, 9:00am UTC](https://discuss.elastic.co/t/nested-document-performance/9821 "2012-11-26T09:00:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Derry\_O\_Sullivan](https://avatars.discourse-cdn.com/v4/letter/d/7bcc69/32.png) [@Derry\_O\_Sullivan](https://discuss.elastic.co/u/Derry_O_Sullivan)\
**Post date:** [November 26, 2012, 9:00am UTC](https://discuss.elastic.co/t/nested-document-performance/9821/1 "2012-11-26T09:00:05Z")

</div>

Hi there,

I'm testing out a design by loading an index (contents - 5 shards, 1  
replica). We want to store user interactions on a document (e.g. a user  
could 'buy'/'sell'/'click' etc) so we want to have generic document  
information stored in the content index (documents type) and a  
document\_interactions type also.

We created the index with ~ 160k parent documents and ~830k nested child  
docs (e.g. average of \>5 documents per parent. The parent/child docs have  
only a few fields (5 each) and are basic types (string, time, boolean)

We then made a query which runs does a boolQuery across the children and  
also the parent.

The first run on a single machine (Intel i7 3Ghz Quad core, 8GB Ram) took  
16 seconds (no warming) with \<100ms for the 2nd run and ~10ms for the 3rd.

I then wanted to see what would happen when i scaled out (i know i have not  
hit the first machines limit yet but wanted to check the effect) and added  
2 more machines (equal spec) to the cluster. My response times now were a  
constant 5-8 seconds.

I was wondering  
a) Is this due to the fact that there is a post aggregation step now by the  
master?  
b) When we tested before with simple queries (e.g. no nesting), we saw that  
scaling out increased performance but here it did not - any idea's if the  
problem is localised to nested child queries?

We are running ES 0.19.11 and testing using the Java API.

Many thanks in advance,

Derry

--

---

<div class="post-metadata">

**Author:** ![mvg](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mvg/32/98890_2.png) [@mvg](https://discuss.elastic.co/u/mvg)\
**Post date:** [November 27, 2012, 6:28am UTC](https://discuss.elastic.co/t/nested-document-performance/9821/2 "2012-11-27T06:28:58Z")

</div>

Hi Derry,

I'm a bit confused here what kind of queries you refer to. (nested  
query or top\_children, has\_child queries, or an combination.).  
Can you perhaps share your search request?

The nodes that contain the shards were the search request gets  
executed on, will be involved in the query. The master node doesn't  
need to be involved with this. I also would expect the performance of  
the query to be increased when adding a node, so what you're  
experiencing is weird.

Martijn

On 26 November 2012 10:00, Derry O' Sullivan [derryos@gmail.com](mailto:derryos@gmail.com) wrote:

> Hi there,
> 
> I'm testing out a design by loading an index (contents - 5 shards, 1  
> replica). We want to store user interactions on a document (e.g. a user  
> could 'buy'/'sell'/'click' etc) so we want to have generic document  
> information stored in the content index (documents type) and a  
> document\_interactions type also.
> 
> We created the index with ~ 160k parent documents and ~830k nested child  
> docs (e.g. average of \>5 documents per parent. The parent/child docs have  
> only a few fields (5 each) and are basic types (string, time, boolean)
> 
> We then made a query which runs does a boolQuery across the children and  
> also the parent.
> 
> The first run on a single machine (Intel i7 3Ghz Quad core, 8GB Ram) took 16  
> seconds (no warming) with \<100ms for the 2nd run and ~10ms for the 3rd.
> 
> I then wanted to see what would happen when i scaled out (i know i have not  
> hit the first machines limit yet but wanted to check the effect) and added 2  
> more machines (equal spec) to the cluster. My response times now were a  
> constant 5-8 seconds.
> 
> I was wondering  
> a) Is this due to the fact that there is a post aggregation step now by the  
> master?  
> b) When we tested before with simple queries (e.g. no nesting), we saw that  
> scaling out increased performance but here it did not - any idea's if the  
> problem is localised to nested child queries?
> 
> We are running ES 0.19.11 and testing using the Java API.
> 
> Many thanks in advance,
> 
> Derry
> 
> --

--  
Met vriendelijke groet,

Martijn van Groningen

--

---

<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 6, 2017, 3:02am UTC](https://discuss.elastic.co/t/nested-document-performance/9821/3 "2017-07-06T03:02:53Z")

</div>


