# How to compare the cost of Search Request

**URL:** <https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881>\
**Category:** Elasticsearch\
**Created:** [April 20, 2020, 2:15pm UTC](https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881 "2020-04-20T14:15:58Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeffzhao](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jeffzhao](https://discuss.elastic.co/u/jeffzhao)\
**Post date:** [April 20, 2020, 2:15pm UTC](https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881/1 "2020-04-20T14:15:58Z")

</div>

Hi,

I want to optimize index settings, for example, customized \_routing parameter, to see if it can improve search performance. The problem is Elasticsearch always cache the query result, so when I run the search for the second time, it's much faster than the first time. I can't baseline the search performance. I tried clear cache but it didn't help.

If the execution time of the search can't tell me whether optimization works, are there any other statistics that I can check? In relational database I can check the EXECUTION PLAN to find the cost of each step. Can I do similar thing in Elasticsearch to find the cost of each Search request?

For my example customized \_routing parameter, I can see the number of shards hit has reduced. But this is not enough to prove the performance has improved.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [April 21, 2020, 10:10pm UTC](https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881/2 "2020-04-21T22:10:16Z")

</div>

Does [https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-profile.html](https://www.elastic.co/guide/en/elasticsearch/reference/7.6/search-profile.html) help?

---

<div class="post-metadata">

**Author:** ![jeffzhao](https://avatars.discourse-cdn.com/v4/letter/j/f1d935/32.png) [@jeffzhao](https://discuss.elastic.co/u/jeffzhao)\
**Post date:** [April 26, 2020, 4:19pm UTC](https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881/3 "2020-04-26T16:19:57Z")

</div>

I'm not sure. Does this Profile API take cache into account?

---

<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:** [May 24, 2020, 4:20pm UTC](https://discuss.elastic.co/t/how-to-compare-the-cost-of-search-request/228881/4 "2020-05-24T16:20:02Z")

</div>

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