Performance of "exists" query

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 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.