# How do you time search query while debugging?

**URL:** <https://discuss.elastic.co/t/how-do-you-time-search-query-while-debugging/252739>\
**Category:** Elasticsearch\
**Created:** [October 20, 2020, 8:48pm UTC](https://discuss.elastic.co/t/how-do-you-time-search-query-while-debugging/252739 "2020-10-20T20:48:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [October 20, 2020, 8:48pm UTC](https://discuss.elastic.co/t/how-do-you-time-search-query-while-debugging/252739/1 "2020-10-20T20:48:18Z")

</div>

I'm currently debugging a slow query issue.  
As expected, the first time query execution is the slowest with subsequent hits way faster due to caching.

As such, what is the best way to get consistent query times so I can debug properly?

Ive thought about using profile API but then it adds significant overhead of its own thus not giving true execution time perhaps?

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [October 21, 2020, 8:24am UTC](https://discuss.elastic.co/t/how-do-you-time-search-query-while-debugging/252739/2 "2020-10-21T08:24:19Z")

</div>

You can try disabling caches (i.e. shard level request cache), but would that help, or does it make more sense to [preload data](https://www.elastic.co/guide/en/elasticsearch/reference/7.9/preload-data-to-file-system-cache.html) before it is made available for search? See

---

<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:** [November 18, 2020, 8:24am UTC](https://discuss.elastic.co/t/how-do-you-time-search-query-while-debugging/252739/3 "2020-11-18T08:24:20Z")

</div>

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