# Msearch speed

**URL:** <https://discuss.elastic.co/t/msearch-speed/117149>\
**Category:** Elasticsearch\
**Created:** [January 26, 2018, 5:39am UTC](https://discuss.elastic.co/t/msearch-speed/117149 "2018-01-26T05:39:43Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jdgenio](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jdgenio](https://discuss.elastic.co/u/jdgenio)\
**Post date:** [January 26, 2018, 5:39am UTC](https://discuss.elastic.co/t/msearch-speed/117149/1 "2018-01-26T05:39:44Z")

</div>

Hi, we're using elasticsearch 5.3.0 and noticed something weird. Here are my queries using \_msearch and \_search:

\_msearch (/\_msearch)

```
{ "index": "us_import", "type": "shipment", "preference": "_replica_first" }
{ "query": { "match_phrase": { "_all": "manga" } }, "_source": [], "size": 0, "aggregations": { "consignee": { "terms": { "field": "Consignee.Name.untouched" } } } }

```

\_search (/us\_import/shipment/\_search?preference=\_replica\_first)

```
{
    "query": {
        "match_phrase": {
            "_all": "manga"
        }
    },
    "aggs": {
        "consignee_terms": {
            "terms": {
                "field": "Consignee.Name.untouched"
            }
        }
    },
    "_source": [],
    "size": 0
}

```

As far as I know, these are identical queries. I was experimenting around msearch and tried these two queries, which should have the same running time but was surprised with the results.

The msearch query took around 4 seconds while the search took around 8, which shouldn't be the case since they are supposedly the same query. Is this because of our elasticsearch version or is msearch really supposed to be faster than the normal search. If so, what is the explanation?

Here are the screenshots of the requests and response times, if you need them. I also make sure to reset the cache before doing these queries.

\_search

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/f/e/fe98b4bf9a48315b43bd9af4a177c2a22c7cb8a7.png)

\_msearch

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/2/32649b220da594f26b4466044564edf4007e29ea.png)

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 29, 2018, 8:32am UTC](https://discuss.elastic.co/t/msearch-speed/117149/2 "2018-01-29T08:32:01Z")

</div>

Hey,

it is very unlikely that msearch is faster than search - slower might make sense as an msearch with more than one request would need for all requests to finish.

In this case it might be that your query is hitting different shards and thus also different nodes. If those nodes have different loads this might result in this.

You could set the preference parameter, to test this out [https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-request-preference.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.1/search-request-preference.html)

--Alex

---

<div class="post-metadata">

**Author:** ![jdgenio](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jdgenio](https://discuss.elastic.co/u/jdgenio)\
**Post date:** [February 7, 2018, 6:18am UTC](https://discuss.elastic.co/t/msearch-speed/117149/3 "2018-02-07T06:18:04Z")

</div>

Hi Alex, thank you for the reply. We made some changes in the past weeks and I can't seem to replicate my problem. Since the changes are related to data nodes setup, I think your hypothesis is right on the spot.

---

<div class="post-metadata">

**Author:** ![jdgenio](https://avatars.discourse-cdn.com/v4/letter/j/b9bd4f/32.png) [@jdgenio](https://discuss.elastic.co/u/jdgenio)\
**Post date:** [February 7, 2018, 6:32am UTC](https://discuss.elastic.co/t/msearch-speed/117149/4 "2018-02-07T06:32:42Z")

</div>

On another note, our main problem still persists. Perhaps you can shed some light on it? I made a new topic.

Here is the link:

> [@Slow terms aggregation speed on ~130M documents](https://discuss.elastic.co/t/slow-terms-aggregation-speed-on-130m-documents/118759):
>
> Environment: ES version: 5.3 Data nodes: 3 We are trying to, through elasticsearch, provide users pregenerated suggestions based on the current dataset (130M documents). The target is to get all unique values of a certain field's property in a certain search. Let's say Field.Name.untouched. Here is the query: { "query":{ "match\_phrase":{ "\_all":"tilapia" } }, "\_source":[], "size":0, "aggregations":{ "suggestions":{ …

---

<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:** [March 7, 2018, 6:32am UTC](https://discuss.elastic.co/t/msearch-speed/117149/5 "2018-03-07T06:32:53Z")

</div>

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