# Rescoring adds unexplained latency to queries

**URL:** <https://discuss.elastic.co/t/rescoring-adds-unexplained-latency-to-queries/359326>\
**Category:** Elasticsearch\
**Created:** [May 12, 2024, 6:57pm UTC](https://discuss.elastic.co/t/rescoring-adds-unexplained-latency-to-queries/359326 "2024-05-12T18:57:49Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nemphys](https://avatars.discourse-cdn.com/v4/letter/n/4af34b/32.png) [@Nemphys](https://discuss.elastic.co/u/Nemphys)\
**Post date:** [May 12, 2024, 6:57pm UTC](https://discuss.elastic.co/t/rescoring-adds-unexplained-latency-to-queries/359326/1 "2024-05-12T18:57:49Z")

</div>

I have created a custom rescorer, following the examples of QueryRescorer / ExampleRescorer.

It works fine, but the latency added to the responses is much bigger than it seemingly should be.

I am using a test query, which consistently takes around 40ms to execute (without rescoring).

When I add my custom rescorer, the response times shoot up to ~130ms.

I have profiled the rescore() method of my custom class and it is consistently executed within 30-35ms. I would expect the total query time to be close to the sum of the plain query and the rescoring, ie. 70-75ms.

What could possibly induce the extra overhead? I looked through the rescoring-related code, but could not find anything suspicious.

Any help would be greatly appreciated.
