# Count or Search with size=0

**URL:** <https://discuss.elastic.co/t/count-or-search-with-size-0/69785>\
**Category:** Elasticsearch\
**Created:** [December 22, 2016, 12:28pm UTC](https://discuss.elastic.co/t/count-or-search-with-size-0/69785 "2016-12-22T12:28:51Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![raj.shah1593](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@raj.shah1593](https://discuss.elastic.co/u/raj.shah1593)\
**Post date:** [December 22, 2016, 12:28pm UTC](https://discuss.elastic.co/t/count-or-search-with-size-0/69785/1 "2016-12-22T12:28:51Z")

</div>

I am using ElasticSearch v2.4.0.

Which operations out of (Count) or (Search with size=0) will be faster in fetching the response count?

Since, count API for Java is deprecated for versions after 2.1.0, Is (Search with size=0) the same in terms of performance or any better operation is available for counting the records?

Thanks in advance.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [December 22, 2016, 2:41pm UTC](https://discuss.elastic.co/t/count-or-search-with-size-0/69785/2 "2016-12-22T14:41:58Z")

</div>

Search with size 0 should be the same performance as count. You can also look at `terminate_after` if you only need a "does this exist".

---

<div class="post-metadata">

**Author:** ![raj.shah1593](https://avatars.discourse-cdn.com/v4/letter/r/8edcca/32.png) [@raj.shah1593](https://discuss.elastic.co/u/raj.shah1593)\
**Post date:** [December 23, 2016, 5:47am UTC](https://discuss.elastic.co/t/count-or-search-with-size-0/69785/3 "2016-12-23T05:47:00Z")

</div>

Hello,

I have millions of documents in my index and I just want the count of the results when I perform a particular search query.

So, will search with size=0 be faster than count in terms of performance, when the data is huge?

---

<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:** [January 20, 2017, 5:47am UTC](https://discuss.elastic.co/t/count-or-search-with-size-0/69785/4 "2017-01-20T05:47:03Z")

</div>

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