# Performance of "exists" query

**URL:** <https://discuss.elastic.co/t/performance-of-exists-query/59591>\
**Category:** Elasticsearch\
**Created:** [September 1, 2016, 6:44pm UTC](https://discuss.elastic.co/t/performance-of-exists-query/59591 "2016-09-01T18:44:43Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![cweiske](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cweiske/32/11732_2.png) [@cweiske](https://discuss.elastic.co/u/cweiske)\
**Post date:** [September 2, 2016, 8:58am UTC](https://discuss.elastic.co/t/performance-of-exists-query/59591/4 "2016-09-02T08:58:27Z")

</div>

I debugged this issue a bit more: Keep-Alive was used automatically, so this was not the problem.

I am using PHP 5.5.9 with the [HTTP\_Request2 library](http://pear.php.net/package/HTTP_Request2) and the socket adapter to send the `_search/exists` GET query with the body.

Switching to the Curl adapter broke, because curl apparently had an issue of sending GET request with a body. Switching to POST made it work with curl, too. Timing did change, too:

- curl with POST: 2.8s
- socket with POST: 18.8s

Then I optimized a bit and used the document's URL as identifier, which means I can now fetch the document with the URL: `GET /document/$url`:

- curl with HEAD on the URL: 1.8s
- socket with HEAD on the URL: 1.3s

Conclusion:

- There is a performance problem in HTTP\_Request2's socket adapter for requests with a body.
- The curl adapter is 10x faster for POST requests
- The socket adapter is 1.5x faster for HEAD requests.

This all had nothing to do with elastic search itself. Sorry.

---

_[View the full topic](https://discuss.elastic.co/t/performance-of-exists-query/59591)._
