# What is the performance impact of using a Match All filter?

**URL:** <https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448>\
**Category:** Elasticsearch\
**Created:** [September 1, 2015, 2:58pm UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448 "2015-09-01T14:58:01Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![anloya](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@anloya](https://discuss.elastic.co/u/anloya)\
**Post date:** [September 1, 2015, 2:58pm UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448/1 "2015-09-01T14:58:01Z")

</div>

As part of query optimization for a project, I'm considering replacing a range filter on document id (cached and due to range passed as parameters, is returning everything like match all) with a match all filter. I'm wondering if this will improve performance?

My assumption is that upon execution the system would simply ignore this filter and I can get improvements in memory+disk usage (removed the cached filter) as well as some execution time. Is this correct?

In context of version 1.7.

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [September 2, 2015, 3:46pm UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448/2 "2015-09-02T15:46:17Z")

</div>

I'm not quite sure I understand your question, you are doing a range filter on a document ID, but you want to replace it with a `match_all` filter?

Is there a reason you aren't use the `ids` filter for this?

---

<div class="post-metadata">

**Author:** ![anloya](https://avatars.discourse-cdn.com/v4/letter/a/5e9695/32.png) [@anloya](https://discuss.elastic.co/u/anloya)\
**Post date:** [September 3, 2015, 8:53am UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448/3 "2015-09-03T08:53:49Z")

</div>

Because I'm not looking for a specific id, but for a range.  
And I don't know if there is any optimization achieved using this filter.

My question -- I have a query designed to take a range of document ids in most scenarios. However, in a special case I pass a range (0, max\_possible\_number) that essentially means return me everything and I'm considering replacing this special case with a Match All filter.

---

<div class="post-metadata">

**Author:** ![dakrone](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dakrone/32/23351_2.png) [@dakrone](https://discuss.elastic.co/u/dakrone)\
**Post date:** [September 3, 2015, 11:23am UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448/4 "2015-09-03T11:23:10Z")

</div>

> However, in a special case I pass a range (0, max\_possible\_number)  
> that essentially means return me everything and I'm considering  
> replacing this special case with a Match All filter.

Okay, I would expect replacing a range over all the ids with a  
`match_all` query to be faster than using the range query.

---

<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:52pm UTC](https://discuss.elastic.co/t/what-is-the-performance-impact-of-using-a-match-all-filter/28448/5 "2017-07-05T23:52:17Z")

</div>


