# Solution for slow queries with parent / child?

**URL:** <https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331>\
**Category:** Elasticsearch\
**Created:** [April 14, 2012, 9:51pm UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331 "2012-04-14T21:51:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AoN](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@AoN](https://discuss.elastic.co/u/AoN)\
**Post date:** [April 14, 2012, 9:51pm UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/1 "2012-04-14T21:51:17Z")

</div>

I am currently wondering if i should use the parent / child feature because  
of the slow query times. I am aware that it is slow because of the ids  
having to be loaded into the memory on the first query. In the index right  
now a parent doc will have many child docs. There will be potentially  
thousands or more parent and child docs being added every second.  
I need to know if there is a solution or planned fix for this?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 17, 2012, 8:08am UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/2 "2012-04-17T08:08:45Z")

</div>

When you say its slow, is it the first part that loads the ids to memory  
that is slow, or the query itself once things are loaded that is slow  
(simply executing the query several times, causing the ids to be loaded,  
and then check how long it takes).

On Sun, Apr 15, 2012 at 12:51 AM, AoN [aonxkilla@gmail.com](mailto:aonxkilla@gmail.com) wrote:

> I am currently wondering if i should use the parent / child feature  
> because of the slow query times. I am aware that it is slow because of the  
> ids having to be loaded into the memory on the first query. In the index  
> right now a parent doc will have many child docs. There will be potentially  
> thousands or more parent and child docs being added every second.  
> I need to know if there is a solution or planned fix for this?

---

<div class="post-metadata">

**Author:** ![AoN](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@AoN](https://discuss.elastic.co/u/AoN)\
**Post date:** [April 17, 2012, 4:51pm UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/3 "2012-04-17T16:51:06Z")

</div>

It's the ids being loaded into the memory that makes it slow not the query  
itself.  
On Tuesday, April 17, 2012 3:08:45 AM UTC-5, kimchy wrote:

> When you say its slow, is it the first part that loads the ids to memory  
> that is slow, or the query itself once things are loaded that is slow  
> (simply executing the query several times, causing the ids to be loaded,  
> and then check how long it takes).
> 
> On Sun, Apr 15, 2012 at 12:51 AM, AoN wrote:
> 
> > I am currently wondering if i should use the parent / child feature  
> > because of the slow query times. I am aware that it is slow because of the  
> > ids having to be loaded into the memory on the first query. In the index  
> > right now a parent doc will have many child docs. There will be potentially  
> > thousands or more parent and child docs being added every second.  
> > I need to know if there is a solution or planned fix for this?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [April 19, 2012, 1:28pm UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/4 "2012-04-19T13:28:13Z")

</div>

I see. We can definitely have another look and see if it can be optimized,  
but the "cost" of it is mostly for the first query where the large time is  
spent.

On Tue, Apr 17, 2012 at 7:51 PM, AoN [aonxkilla@gmail.com](mailto:aonxkilla@gmail.com) wrote:

> It's the ids being loaded into the memory that makes it slow not the query  
> itself.
> 
> On Tuesday, April 17, 2012 3:08:45 AM UTC-5, kimchy wrote:
> 
> > When you say its slow, is it the first part that loads the ids to memory  
> > that is slow, or the query itself once things are loaded that is slow  
> > (simply executing the query several times, causing the ids to be loaded,  
> > and then check how long it takes).
> > 
> > On Sun, Apr 15, 2012 at 12:51 AM, AoN wrote:
> > 
> > I am currently wondering if i should use the parent / child feature
> > 
> > > because of the slow query times. I am aware that it is slow because of the  
> > > ids having to be loaded into the memory on the first query. In the index  
> > > right now a parent doc will have many child docs. There will be potentially  
> > > thousands or more parent and child docs being added every second.  
> > > I need to know if there is a solution or planned fix for this?

---

<div class="post-metadata">

**Author:** ![AoN](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@AoN](https://discuss.elastic.co/u/AoN)\
**Post date:** [April 19, 2012, 4:32pm UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/5 "2012-04-19T16:32:02Z")

</div>

Thanks! Let me know if you can optimize it.

On Thursday, April 19, 2012 8:28:13 AM UTC-5, kimchy wrote:

> I see. We can definitely have another look and see if it can be optimized,  
> but the "cost" of it is mostly for the first query where the large time is  
> spent.
> 
> On Tue, Apr 17, 2012 at 7:51 PM, AoN wrote:
> 
> > It's the ids being loaded into the memory that makes it slow not the  
> > query itself.
> > 
> > On Tuesday, April 17, 2012 3:08:45 AM UTC-5, kimchy wrote:
> > 
> > > When you say its slow, is it the first part that loads the ids to memory  
> > > that is slow, or the query itself once things are loaded that is slow  
> > > (simply executing the query several times, causing the ids to be loaded,  
> > > and then check how long it takes).
> > > 
> > > On Sun, Apr 15, 2012 at 12:51 AM, AoN wrote:
> > > 
> > > I am currently wondering if i should use the parent / child feature
> > > 
> > > > because of the slow query times. I am aware that it is slow because of the  
> > > > ids having to be loaded into the memory on the first query. In the index  
> > > > right now a parent doc will have many child docs. There will be potentially  
> > > > thousands or more parent and child docs being added every second.  
> > > > I need to know if there is a solution or planned fix for this?

---

<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:31am UTC](https://discuss.elastic.co/t/solution-for-slow-queries-with-parent-child/7331/6 "2017-07-06T03:31:52Z")

</div>


