# Why match\_all is slower than range filter?

**URL:** <https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133>\
**Category:** Elasticsearch\
**Created:** [April 2, 2016, 2:05pm UTC](https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133 "2016-04-02T14:05:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![vorou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vorou/32/8377_2.png) [@vorou](https://discuss.elastic.co/u/vorou)\
**Post date:** [April 2, 2016, 2:05pm UTC](https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133/1 "2016-04-02T14:05:32Z")

</div>

ES 1.5.2  
Here's the queries, from slowest to faster (I ran all of them multiple times):

`"query":{"match_all": {}}`  
~200ms

```
{
    "query": {
        "filtered": {
           "filter": {
               "range": {
                  "indexedDateTime": {
                     "from": "2014-01-01"
                  }
               }
           }
        }
    }
}

```

~150ms

```
{
    "query": {
        "filtered": {
           "filter": {
               "range": {
                  "indexedDateTime": {
                     "from": "2016-01-01"
                  }
               }
           }
        }
    }
}

```

~20ms

The average response time correlates with total numbers of document returned and I don't quite understand why, since I'm asking for no documents (the times will be the same if add `size: 0`). I thought `match_all` should be fastest of all since elastic shouldn't do any work, and range filter time should only depend on total number of documents in index, since it uses either fielddata or inverted index, so it shouldn't care for number of matching documents.

What am I missing here?

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [April 2, 2016, 4:24pm UTC](https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133/2 "2016-04-02T16:24:09Z")

</div>

Upgrade to 2.x.

You will notice the difference 🙂

---

<div class="post-metadata">

**Author:** ![vorou](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/vorou/32/8377_2.png) [@vorou](https://discuss.elastic.co/u/vorou)\
**Post date:** [April 4, 2016, 4:57pm UTC](https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133/3 "2016-04-04T16:57:13Z")

</div>

Yeah, we've been thinking of it for some time. Not a trivial thing to do.

Still interested in explanation of this version behavior.

---

<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:** [July 5, 2017, 11:02pm UTC](https://discuss.elastic.co/t/why-match-all-is-slower-than-range-filter/46133/4 "2017-07-05T23:02:32Z")

</div>


