# Parent Child queries running slow

**URL:** <https://discuss.elastic.co/t/parent-child-queries-running-slow/56850>\
**Category:** Elasticsearch\
**Created:** [August 1, 2016, 3:58am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850 "2016-08-01T03:58:04Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![bhaskerreddyb](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@bhaskerreddyb](https://discuss.elastic.co/u/bhaskerreddyb)\
**Post date:** [August 1, 2016, 3:58am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/1 "2016-08-01T03:58:04Z")

</div>

Here is my current elsticsearch dataset layout. We are using parent child type mapping for our data.  
We have around 100 million parents and 3 billion childs for this parents.  
My Index mapping:  
{  
geneticsdb\_v4: {  
mappings: {  
variant: {  
properties: {}  
},  
allelefreq: {  
\_parent:{type:variant},  
properties:{}  
},  
}  
}  
}  
I loaded my all documents to above index with above mentioned mapping.  
Now I am trying to retrieve data using has\_child queries but they became very slow.  
I am trying improve my index performance using fielddata.  
"fielddata": {  
"loading": "eager\_global\_ordinals"

I update my index mapping for fielddata on \_parent. After I ran this here is my current mapping:

{  
My\_index: {  
mappings: {  
variant: {  
properties: {}  
},  
allelefreq: {  
\_parent: {  
type: "variant",  
**fielddata: {**  
**loading: "eager\_global\_ordinals"**  
}  
},  
properties: {}  
},  
}  
}  
}

Still my queries running slow even after updating my mapping.

Do I need to reindex whole data ?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 2, 2016, 10:16am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/2 "2016-08-02T10:16:13Z")

</div>

> [@bhaskerreddyb](#):
>
> 100 million parents and 3 billion childs

That is a lot.

How many nodes do you have? What version are you on? What is their config?

---

<div class="post-metadata">

**Author:** ![bhaskerreddyb](https://avatars.discourse-cdn.com/v4/letter/b/ecd19e/32.png) [@bhaskerreddyb](https://discuss.elastic.co/u/bhaskerreddyb)\
**Post date:** [August 4, 2016, 5:26am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/3 "2016-08-04T05:26:17Z")

</div>

We have around 10 nodes and index created on 24 shards. Each shard size is around 240 GB.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 4, 2016, 6:30am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/4 "2016-08-04T06:30:31Z")

</div>

That's **very** large. I'd suggest you may need more nodes.

What version are you on?

---

<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:** [August 4, 2016, 8:07am UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/5 "2016-08-04T08:07:50Z")

</div>

Shard size will affect query latency, and those shards are considerably larger than what we usually recommend. Queries are executed in parallel against all shards, but each shard is processed in a single threaded. Having few, large shards can therefore be slow and limit the amount of concurrent processing. Create an index with a single shard and gradually increase the data volume while running queries and monitoring the latencies. This should give you an idea about the maximum shard size you should aim for.

---

<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 5, 2017, 10:30pm UTC](https://discuss.elastic.co/t/parent-child-queries-running-slow/56850/6 "2017-07-05T22:30:12Z")

</div>


