# Why does the query response time optimized significantly after disabling indices.queries.cache.size

**URL:** <https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204>\
**Category:** Elasticsearch\
**Created:** [January 30, 2023, 9:16am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204 "2023-01-30T09:16:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![xiaodid](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xiaodid/32/116507_2.png) [@xiaodid](https://discuss.elastic.co/u/xiaodid)\
**Post date:** [January 30, 2023, 9:16am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/1 "2023-01-30T09:16:21Z")

</div>

We have a ES 7.9.16 cluster which has 1 master node and 3 data nodes. Each data node has 31 Gb heap size.

We created 2 indexes, each index contains 2.5 billion docs. The query response time is about 1 second while query those 2 indexes.

After disabling indices.queries.cache.size (set it to 0), the response time drops to 10 ms while running the same DSL.

Could you please help us accounting for the root cause of this?  
Is disabling caching a good optimization?

Thank you very much.

---

<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:** [January 31, 2023, 4:00am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/2 "2023-01-31T04:00:02Z")

</div>

Welcome to our community! 😃  
Please note that version is [EOL](https://www.elastic.co/support/eol) and no longer supported, you should be looking to upgrade as a matter of urgency.

What is the mapping? What is the query? What is your Elasticsearch configuration?

Also - why do you have 1 master but 3 data nodes? That's not ideal fo 7.X of Elasticsearch.

---

<div class="post-metadata">

**Author:** ![Liaowei](https://avatars.discourse-cdn.com/v4/letter/l/9fc348/32.png) [@Liaowei](https://discuss.elastic.co/u/Liaowei)\
**Post date:** [January 31, 2023, 6:55am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/3 "2023-01-31T06:55:48Z")

</div>

Hi, Mark, thanks so much for answering our question. We have a boolean query dsl whick consists of a filter context and a should phrase. The filter context consists of a range query for timeline and a terms query, which we used to filter what matches the terms phrase and timeline between the range. The should phrase consists of a multi\_match query, accordingly used to match subset of contents of the filter context. the query pattern looks like this:

```auto
"query": {
	"bool": {
	    "fitler": [
		{"range": {}},
		{"terms": {}}
	   ],
	   "should": [
		{"multi_match": {}}
	  ]
   }
}

```

About Elasticseach configuration: actually we did use default configurations by Elasticsearch, we have only disabled indices.queries.cache.size (set it to 0).  
About cluster roles: It's only a test environment, so we have cut down some nodes.  
We are really confused of the test results. Thanks again for helping us.

---

<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:** [January 31, 2023, 7:22am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/4 "2023-01-31T07:22:49Z")

</div>

> [@Liaowei](#):
>
> About Elasticseach configuration: actually we did use default configurations by Elasticsearch, we have only disabled indices.queries.cache.size (set it to 0).

Does that mean you are using the default heap? You must have changed something to cluster the nodes, so it'd be good if you shared your config.

It'd also be good to understand the mappings. And while that's a great start on sharing the query, how many actual search terms are you adding into the `terms` and `multi_match` values?

---

<div class="post-metadata">

**Author:** ![Liaowei](https://avatars.discourse-cdn.com/v4/letter/l/9fc348/32.png) [@Liaowei](https://discuss.elastic.co/u/Liaowei)\
**Post date:** [January 31, 2023, 8:18am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/5 "2023-01-31T08:18:17Z")

</div>

Well, the heap size for data nodes was 31Gb respectively and master node was 16Gb, and we use G1 GC. I am able to paste serveral configurations .

```auto
master node:
node.master: true
node.data: false
node.ingest: false
search.remote.connect: false
node.ml: false
bootstrap.memory_lock:true
cluster.remote.connect: true
cluster.max_shards_per_node: 20000
cluster.routing.allocation.node_initial_primaries_recoveries: 32
cluster.routing.allocation.node_concurrent_recoveries: 32
cluster.routing.allocation.cluster_concurrent_rebalance: 32
cluster.routing.allocation.disk.include_relocations: false

data nodes:
node.master: false
node.data: true
node.ingest: false
search.remote.connect: false
node.ml: false
bootstrap.memory_lock:true
cluster.remote.connect: true
cluster.max_shards_per_node: 20000
cluster.routing.allocation.node_initial_primaries_recoveries: 32
cluster.routing.allocation.node_concurrent_recoveries: 32
cluster.routing.allocation.cluster_concurrent_rebalance: 32
cluster.routing.allocation.disk.include_relocations: false
indices.queries:cache.size: 0%

```

terms phrase contains only a term,which is an array, array length varies from 1 to 6, those are our common cases.  
multi\_match is a 9 fields query.

mapping:

```auto
"mapping": {
	"dynamic": "strict",
	"properties": {
		"accoNo": {
			"type": "keyword"
		},
		"typeName": {
			"analyzer": "standard",
			"type": "text"
		},
		"time": {
			"format": "yyyyMMddHHmmss",
			"type": "date"
		},
		"remark": {
			"analyzer": "standard",
			"type": "text"
		},
		"channl": {
			"analyzer": "standard",
			"type": "text"
		},
		"desc": {
			"analyzer": "standard",
			"type": "text"
		},
		"summName": {
			"analyzer": "standard",
			"type": "text"
		},
		"telNo": {
			"analyzer": "standard",
			"type": "text"
		},
		"opsName": {
			"analyzer": "standard",
			"type": "text"
		},
		"companyName": {
			"analyzer": "standard",
			"type": "text"
		},
		"tacctScrt": {
			"analyzer": "standard",
			"type": "text"
		},
		...
	}
}

```

DSL :

```auto
"query": {
	"bool": {
	    "fitler": [
		{ 
			"range": {
				"time": {
					"from": "20200101000000"
					"to": "20210101000000"
				}
			}
		},
		{
			"terms": {
				"accoNo": [
					"00000000000000001",
					"00000000000000002"
				]
			}
		}
	   ],
	   "should": [
		{
			"multi_match": {
				"query": "some words",
				"fields": [
					"channl",
					"typeName",
					"desc",
					"summName",
					"telNo",
					"opsName",
					"companyName",
					"remark",
					"tacctScrt"
				],
				"type": "phrase",
				"operator": "or",
				"slop": 3
			}
		}
	  ]
   }
}

```

---

<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:** [February 28, 2023, 8:19am UTC](https://discuss.elastic.co/t/why-does-the-query-response-time-optimized-significantly-after-disabling-indices-queries-cache-size/324204/6 "2023-02-28T08:19:03Z")

</div>

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