# Elasticsearch async search very slow

**URL:** <https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016>\
**Category:** Elasticsearch\
**Tags:** async-search\
**Created:** [September 8, 2022, 6:40pm UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016 "2022-09-08T18:40:39Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![bonyolult](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bonyolult](https://discuss.elastic.co/u/bonyolult)\
**Post date:** [September 8, 2022, 6:40pm UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/1 "2022-09-08T18:40:39Z")

</div>

I'm running queries on a 3 node cluster. Simple query\_string query with some wildcards. When i use \_search, it takes about 10-15 ms to execute the query but when using \_async\_search query time goes up to around 300 000 ms. Can anybody help, what could be wrong? The queries are exactly the same, Elasticsearch 7.17.5 has 8 GB heap set, 2 vcores, nothing else is running on those machines. The data set is on 1 shard and occupies ~160 GB (this is a test env.) No matter if i search in one index or multiple indexes, it's very\_veeery\_veeeeery slow. Maybe a "hidden" setting should be adjusted to get acceptable performance? Thank you!

---

<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:** [September 8, 2022, 9:03pm UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/2 "2022-09-08T21:03:08Z")

</div>

Welcome to our community! 😃

Why are you using async if it's that fast normally? Please also share your query.

---

<div class="post-metadata">

**Author:** ![bonyolult](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bonyolult](https://discuss.elastic.co/u/bonyolult)\
**Post date:** [September 9, 2022, 7:20am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/3 "2022-09-09T07:20:23Z")

</div>

The business req. is to search in a huge amount of log records in a case insensitive manner w. wildcards (to search for anything, anyhow). Sometimes these take longer and we receive SocketTimeoutException, so the "saying" is to search asynchronously and polling ES with the query ID if it has finished or not. Once the relevant records are identified, the data is queried synchronously with the document id list and w. search\_after. That's why i need async search.  
The query is irrelevant, practically all queries run 10x 20x times slower when using async search.  
A sample req:

```auto
POST somindex/_async_search?allow_partial_search_results=true&request_cache=true&wait_for_completion_timeout=0s
{
  "track_total_hits": true,
  "size": 2000,
  "query": {
    "query_string": {
      "default_field": "original_data",
      "query": "*text1* AND *text2*"
    }
  },
  "_source": "mqBody.id"
}

```

---

<div class="post-metadata">

**Author:** ![bonyolult](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bonyolult](https://discuss.elastic.co/u/bonyolult)\
**Post date:** [September 9, 2022, 7:27am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/4 "2022-09-09T07:27:53Z")

</div>

I just haven't found any posts or issues on incredibly slow async search, so i thought there might be some misconfiguration on our site. Or...simply nobody uses async search because it is really that slow?

---

<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:** [September 9, 2022, 7:31am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/5 "2022-09-09T07:31:18Z")

</div>

> [@bonyolult](#):
>
> When i use \_search, it takes about 10-15 ms to execute the query but when using \_async\_search query time goes up to around 300 000 ms.

Are you saying that a query that in normal mode takes 15ms all of a sudden taken 5 minutes when run in async mode?

> [@bonyolult](#):
>
> The query is irrelevant, practically all queries run 10x 20x times slower when using async search.

This statement seem to contradict the previous one. 20 times 15ms is only 300ms, not 5 minutes.

It would be useful to get some real data and practical examples.

Be aware that async search is designed for handling long running queries and does a lot more work than a simple search in that it handles the execution of the query and recording of partial results that are used to get the final result.

---

<div class="post-metadata">

**Author:** ![bonyolult](https://avatars.discourse-cdn.com/v4/letter/b/e36b37/32.png) [@bonyolult](https://discuss.elastic.co/u/bonyolult)\
**Post date:** [September 9, 2022, 7:47am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/6 "2022-09-09T07:47:13Z")

</div>

Yes, your're right, sorry, i confused seconds w. milliseconds. \_seach w. the above query runs for ~15ms, with \_async\_search it runs for ~300 000 ms.  
Unfortunately i can't share any data because it's **strictly** confidential. But i must explain to our customer why we can't use async or if we do, why it will be so painfully slow.  
In case there's some more deatiled documentation then the official one for diving deeper into how async search works under the hood, i'd really appreciate it.  
As far as i know, simple search results are also stored in the .search system index, so the fact that query result are stored, in itself doesn't explain this huge difference in running times.

---

<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:** [September 9, 2022, 7:54am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/7 "2022-09-09T07:54:52Z")

</div>

> [@bonyolult](#):
>
> ~15ms, with \_async\_search it runs for ~300 000 ms.

So it increases from 15ms to 5 minutes (300s = 300000ms)? I find that hard to believe.

> [@bonyolult](#):
>
> As far as i know, simple search results are also stored in the .search system index

The result of normal queries are not persisted to disk at any stage.

---

<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:** [October 7, 2022, 7:55am UTC](https://discuss.elastic.co/t/elasticsearch-async-search-very-slow/314016/8 "2022-10-07T07:55:46Z")

</div>

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