# Latency issues when using nested queries and inner hists

**URL:** <https://discuss.elastic.co/t/latency-issues-when-using-nested-queries-and-inner-hists/279711>\
**Category:** Elasticsearch\
**Created:** [July 27, 2021, 9:34am UTC](https://discuss.elastic.co/t/latency-issues-when-using-nested-queries-and-inner-hists/279711 "2021-07-27T09:34:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![wedul](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/wedul/32/92187_2.png) [@wedul](https://discuss.elastic.co/u/wedul)\
**Post date:** [July 27, 2021, 9:34am UTC](https://discuss.elastic.co/t/latency-issues-when-using-nested-queries-and-inner-hists/279711/1 "2021-07-27T09:34:47Z")

</div>

I have two questions while using elasticsearch.

using version : 7.1.1  
index cluster: master node: 5, client node 6, data node 18, 4 shard, 10gb  
search rate : about 5~600 tps  
index mapping example:

```auto
{
	"mappings": {
		"properties": {
			"agencyId": {
				"type": "integer"
			},
			"products": {
				"type": "nested",
				"properties": {
					"name": {
						"type": "text"
					}
				}
			}
		}
	}
}

```

Question.

1. As you can see from the mapping example above, nested query and innerhits are used together for search while inevitably using elasticsearch. I know both queries are not performing well, so I'm wondering what can be done to further improve performance in this situation. For example, specify innertHits source and size, or adjust the number of shards well.

2. In the above situation, latency jumps about once every 10 to 20 seconds, but the average latency is at a stable level. The index is updated at about 50k per minute and I wonder if this can have an effect or if there are other factors.

Thank you and look forward to your reply.

---

<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:** [August 24, 2021, 9:35am UTC](https://discuss.elastic.co/t/latency-issues-when-using-nested-queries-and-inner-hists/279711/2 "2021-08-24T09:35:48Z")

</div>

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