# Ids query is faster very much than ids filter ,why?

**URL:** <https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421>\
**Category:** Elasticsearch\
**Created:** [March 25, 2016, 6:30am UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421 "2016-03-25T06:30:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![whybangbang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whybangbang/32/7116_2.png) [@whybangbang](https://discuss.elastic.co/u/whybangbang)\
**Post date:** [March 25, 2016, 6:30am UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/1 "2016-03-25T06:30:27Z")

</div>

i send a ids filter to es ,the took in response is average of 30,but when replace by ids query,the took is 1 or 2.  
why?  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/8/84284950becec64f7e293318067ee17ea3c17755.png)  
 ![](https://us1.discourse-cdn.com/elastic/original/2X/1/1546598110838391228944cfa764fdc2d4066231.png)

---

<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:** [March 25, 2016, 7:36am UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/2 "2016-03-25T07:36:02Z")

</div>

That won't be an issue anymore with 2.x as query and filters are now merged.

The difference is probably due to scoring computation for queries which is not the case for filters.  
Plus filters can be cached. Not queries

---

<div class="post-metadata">

**Author:** ![whybangbang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whybangbang/32/7116_2.png) [@whybangbang](https://discuss.elastic.co/u/whybangbang)\
**Post date:** [March 28, 2016, 10:33am UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/3 "2016-03-28T10:33:37Z")

</div>

thank you for your reply, but i can't understand why query is faster，if you can provide some url to explain this case? thank you

---

<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:** [March 28, 2016, 6:00pm UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/4 "2016-03-28T18:00:46Z")

</div>

I misread your original post. Sorry.  
Do you have the exact same response time (order of magnitude) when you restart the node before running each query?

I think it's related to the cache.

---

<div class="post-metadata">

**Author:** ![whybangbang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/whybangbang/32/7116_2.png) [@whybangbang](https://discuss.elastic.co/u/whybangbang)\
**Post date:** [April 8, 2016, 4:45am UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/5 "2016-04-08T04:45:15Z")

</div>

thank you for your reply ,maybe in this case ,query is enough and we have choose query not filter .  
can you solve our' a other problem[link](https://discuss.elastic.co/t/elasticsearch-1-7-4-only-one-node-queue-is-full-other-is-normal-maybe-is-a-bug/46759)

our produce cluster upgrade to 1.7.4 from 1.5.2 yesterday，but problem happen

---

<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:01pm UTC](https://discuss.elastic.co/t/ids-query-is-faster-very-much-than-ids-filter-why/45421/6 "2017-07-05T23:01:18Z")

</div>


