# Slow child query: Elasticsearch parent child query profile analysis showing using time for unrealetd children I was not quering

**URL:** https://discuss.elastic.co/t/slow-child-query-elasticsearch-parent-child-query-profile-analysis-showing-using-time-for-unrealetd-children-i-was-not-quering/180066
**Category:** Elasticsearch
**Created:** [May 7, 2019, 9:15pm UTC](https://discuss.elastic.co/t/slow-child-query-elasticsearch-parent-child-query-profile-analysis-showing-using-time-for-unrealetd-children-i-was-not-quering/180066 "2019-05-07T21:15:25Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![jasonzhang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jasonzhang/32/45777_2.png) [@jasonzhang](https://discuss.elastic.co/u/jasonzhang)
#### Post date: [May 7, 2019, 9:15pm UTC](https://discuss.elastic.co/t/slow-child-query-elasticsearch-parent-child-query-profile-analysis-showing-using-time-for-unrealetd-children-i-was-not-quering/180066/1 "2019-05-07T21:15:25Z")

</div>

I have join type field mapping,

```
{
	"properties": {
		"data_type": {
			"type": "join",
			"eager_global_ordinals": true,
			"relations": {
				"contact": [
					"user_published_contact",
					"crm_lead_email",
					"crm_contact_email"
				],
				"company": [
					"user_published_company",
					"audience_company",
					"crm_account",
					"model_fitscore",
					"exclusion_company",
					"company_intent",
					"crm_contact",
					"company_department",
					"crm_lead",
					"business_tags",
					"contact",
					"company_ucc_insights",
					"similar_domain"
				]
			}
		}
	}
}

```

But when I try to only query one type of child with profile api, it returns the following result:  
Query:

```
    GET eap_company_20190325_v2/_search
{
  "profile": true,
  "size": 10,
  "query": {
    "bool": {
      "filter": [
        {
          "term": {
            "data_type": "model_fitscore"
          }
        },
        {
          "term": {
            "model_id": 10000001
          }
        },
        {
          "has_parent": {
            "parent_type": "company",
            "query": {
              "bool": {
                "filter": [
                  {
                    "term": {
                      "use_case": 1
                    }
                  },
                  {
                    "has_child": {
                      "type": "crm_lead",
                      "query": {
                        "bool": {
                          "must": [
                            {
                              "term": {
                                "domain": "ibm.com"
                              }
                            }
                          ]
                        }
                      }
                    }
                  }
                ]
              }
            }
          }
        }
      ]
    }
  }
}

```

Partial Result:

```
"children": [
                              {
                                "type": "TermQuery",
                                "description": "data_type:user_published_company",
                                "time_in_nanos": 73333,
                                "breakdown": {
                                  "score": 0,
                                  "build_scorer_count": 26,
                                  "match_count": 0,
                                  "create_weight": 645,
                                  "next_doc": 0,
                                  "match": 0,
                                  "create_weight_count": 1,
                                  "next_doc_count": 0,
                                  "score_count": 0,
                                  "build_scorer": 61047,
                                  "advance": 11611,
                                  "advance_count": 3
                                }
                              }

```

Can anyone let me know why it showing other types(for example, user\_published\_company) of children(which I didn't query) profile context which may contribute the query slowness?

 ![es_profile](https://us1.discourse-cdn.com/elastic/original/3X/4/7/47088a43799e8950d8ca5dd79c5fc857086e118b.jpeg)

---

<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: [June 4, 2019, 9:15pm UTC](https://discuss.elastic.co/t/slow-child-query-elasticsearch-parent-child-query-profile-analysis-showing-using-time-for-unrealetd-children-i-was-not-quering/180066/2 "2019-06-04T21:15:26Z")

</div>

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