# Elapsed query time?

**URL:** <https://discuss.elastic.co/t/elapsed-query-time/2836>\
**Category:** Elasticsearch\
**Created:** [March 4, 2010, 3:32pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836 "2010-03-04T15:32:06Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stephen\_Smith](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Stephen\_Smith](https://discuss.elastic.co/u/Stephen_Smith)\
**Post date:** [March 4, 2010, 3:32pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/1 "2010-03-04T15:32:06Z")

</div>

Is it possible to get the search query time from the server to enable  
Google-style "Searched 45,000 documents in 0.03 seconds"-type  
reporting for logging or to show to end users?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 4:00pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/2 "2010-03-04T16:00:41Z")

</div>

It can be added, but you can also add it around the search request, no?

On Thu, Mar 4, 2010 at 5:32 PM, Stephen Smith [stephen.smith@gmail.com](mailto:stephen.smith@gmail.com)wrote:

> Is it possible to get the search query time from the server to enable  
> Google-style "Searched 45,000 documents in 0.03 seconds"-type  
> reporting for logging or to show to end users?

---

<div class="post-metadata">

**Author:** ![Stephen\_Smith](https://avatars.discourse-cdn.com/v4/letter/s/f1d935/32.png) [@Stephen\_Smith](https://discuss.elastic.co/u/Stephen_Smith)\
**Post date:** [March 4, 2010, 4:59pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/3 "2010-03-04T16:59:39Z")

</div>

I could, but that number would reflect HTTP transport time that might  
vary independently of the time Elasticsearch takes to complete an  
operation. If a query takes 500ms to complete, it might be helpful (at  
least for debugging) for the app to know how much of the time is spent  
in ES.

On Mar 4, 11:00 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:

> It can be added, but you can also add it around the search request, no?
> 
> On Thu, Mar 4, 2010 at 5:32 PM, Stephen Smith [stephen.sm...@gmail.com](mailto:stephen.sm...@gmail.com)wrote:
> 
> > Is it possible to get the search query time from the server to enable  
> > Google-style "Searched 45,000 documents in 0.03 seconds"-type  
> > reporting for logging or to show to end users?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 5:02pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/4 "2010-03-04T17:02:03Z")

</div>

Agreed. This, by the way, does not apply only to the search API but to all  
APIs. I just hate taking the system time when I can avoid it, so maybe it  
will be optional?

-shay.banon

On Thu, Mar 4, 2010 at 6:59 PM, Stephen Smith [stephen.smith@gmail.com](mailto:stephen.smith@gmail.com)wrote:

> I could, but that number would reflect HTTP transport time that might  
> vary independently of the time Elasticsearch takes to complete an  
> operation. If a query takes 500ms to complete, it might be helpful (at  
> least for debugging) for the app to know how much of the time is spent  
> in ES.
> 
> On Mar 4, 11:00 am, Shay Banon [shay.ba...@elasticsearch.com](mailto:shay.ba...@elasticsearch.com) wrote:
> 
> > It can be added, but you can also add it around the search request, no?
> > 
> > On Thu, Mar 4, 2010 at 5:32 PM, Stephen Smith \<[stephen.sm...@gmail.com](mailto:stephen.sm...@gmail.com)  
> > wrote:
> > 
> > > Is it possible to get the search query time from the server to enable  
> > > Google-style "Searched 45,000 documents in 0.03 seconds"-type  
> > > reporting for logging or to show to end users?

---

<div class="post-metadata">

**Author:** ![Sergio\_Bossa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergio_bossa/32/3312_2.png) [@Sergio\_Bossa](https://discuss.elastic.co/u/Sergio_Bossa)\
**Post date:** [March 4, 2010, 5:07pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/5 "2010-03-04T17:07:21Z")

</div>

On Thu, Mar 4, 2010 at 6:02 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Agreed. This, by the way, does not apply only to the search API but to all  
> APIs. I just hate taking the system time when I can avoid it, so maybe it  
> will be optional?

What about providing some kind of interceptor API on top of your HTTP module?

--  
Sergio Bossa  
[http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 5:25pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/6 "2010-03-04T17:25:35Z")

</div>

Yes, interceptor level APIs is the way to go. In terms of implementation  
though, there is the HTTP module and there is the Transport module, in this  
case, you would want to do it on the transport level so other APIs (the HTTP  
among them, but Java API and so on) will get it for free.

-shay.banon

On Thu, Mar 4, 2010 at 7:07 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com) wrote:

> On Thu, Mar 4, 2010 at 6:02 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> wrote:
> 
> > Agreed. This, by the way, does not apply only to the search API but to  
> > all  
> > APIs. I just hate taking the system time when I can avoid it, so maybe it  
> > will be optional?
> 
> What about providing some kind of interceptor API on top of your HTTP  
> module?
> 
> --  
> Sergio Bossa  
> [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![Sergio\_Bossa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergio_bossa/32/3312_2.png) [@Sergio\_Bossa](https://discuss.elastic.co/u/Sergio_Bossa)\
**Post date:** [March 4, 2010, 5:29pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/7 "2010-03-04T17:29:01Z")

</div>

On Thu, Mar 4, 2010 at 6:25 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> Yes, interceptor level APIs is the way to go. In terms of implementation  
> though, there is the HTTP module and there is the Transport module, in this  
> case, you would want to do it on the transport level

So does the transport level get fired even for _local_ calls (that is,  
requests answered by the node itself)?

--  
Sergio Bossa  
[http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 5:30pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/8 "2010-03-04T17:30:42Z")

</div>

Yes, they do. Its not really the transport module, more the Transport based  
APIs, which have a single point entry for each API regardless if it ends up  
being called locally or remotely.

-shay.banon

On Thu, Mar 4, 2010 at 7:29 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com) wrote:

> On Thu, Mar 4, 2010 at 6:25 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> wrote:
> 
> > Yes, interceptor level APIs is the way to go. In terms of implementation  
> > though, there is the HTTP module and there is the Transport module, in  
> > this  
> > case, you would want to do it on the transport level
> 
> So does the transport level get fired even for _local_ calls (that is,  
> requests answered by the node itself)?
> 
> --  
> Sergio Bossa  
> [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 5:36pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/9 "2010-03-04T17:36:55Z")

</div>

One more note, because of the async nature of elasticsearch (completely  
async tcp for example), its not simple to write an interceptor. The "before"  
will probably need to create a Context, which will be passed to the "after".

-shay.banon

On Thu, Mar 4, 2010 at 7:30 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)wrote:

> Yes, they do. Its not really the transport module, more the Transport based  
> APIs, which have a single point entry for each API regardless if it ends up  
> being called locally or remotely.
> 
> -shay.banon
> 
> On Thu, Mar 4, 2010 at 7:29 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com)wrote:
> 
> > On Thu, Mar 4, 2010 at 6:25 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> > wrote:
> > 
> > > Yes, interceptor level APIs is the way to go. In terms of implementation  
> > > though, there is the HTTP module and there is the Transport module, in  
> > > this  
> > > case, you would want to do it on the transport level
> > 
> > So does the transport level get fired even for _local_ calls (that is,  
> > requests answered by the node itself)?
> > 
> > --  
> > Sergio Bossa  
> > [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![Sergio\_Bossa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sergio_bossa/32/3312_2.png) [@Sergio\_Bossa](https://discuss.elastic.co/u/Sergio_Bossa)\
**Post date:** [March 4, 2010, 5:45pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/10 "2010-03-04T17:45:51Z")

</div>

On Thu, Mar 4, 2010 at 6:36 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com) wrote:

> One more note, because of the async nature of elasticsearch (completely  
> async tcp for example),

Is it async meaning it doesn't wait for the indexing response? Or does  
it rather wait by using some kind of continuation?

--  
Sergio Bossa  
[http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![Lukas\_Vlcek1](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/lukas_vlcek1/32/819_2.png) [@Lukas\_Vlcek1](https://discuss.elastic.co/u/Lukas_Vlcek1)\
**Post date:** [March 4, 2010, 7:18pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/11 "2010-03-04T19:18:48Z")

</div>

Hi,

I think that what Shay meant was that in ES Java API you get ActionFuture as  
a response when submitting a request. It is based on Java Future API (  
[Future (Java Platform SE 6)](http://java.sun.com/javase/6/docs/api/java/util/concurrent/Future.html)).

See  
org.elasticsearch.action.Action[http://github.com/elasticsearch/elasticsearch/blob/b3337c312765e51cec7bde5883bbc0a08f56fb65/modules/elasticsearch/src/main/java/org/elasticsearch/action/Action.java](http://github.com/elasticsearch/elasticsearch/blob/b3337c312765e51cec7bde5883bbc0a08f56fb65/modules/elasticsearch/src/main/java/org/elasticsearch/action/Action.java)  
org.elasticsearch.action.ActionFuture[http://github.com/elasticsearch/elasticsearch/blob/b3337c312765e51cec7bde5883bbc0a08f56fb65/modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionFuture.java](http://github.com/elasticsearch/elasticsearch/blob/b3337c312765e51cec7bde5883bbc0a08f56fb65/modules/elasticsearch/src/main/java/org/elasticsearch/action/ActionFuture.java)

Lukas

On Thu, Mar 4, 2010 at 6:45 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com) wrote:

> On Thu, Mar 4, 2010 at 6:36 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> wrote:
> 
> > One more note, because of the async nature of elasticsearch (completely  
> > async tcp for example),
> 
> Is it async meaning it doesn't wait for the indexing response? Or does  
> it rather wait by using some kind of continuation?
> 
> --  
> Sergio Bossa  
> [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [March 4, 2010, 8:15pm UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/12 "2010-03-04T20:15:41Z")

</div>

Yes, its basically continuation. All of elasticsearch is built on top to not  
blocking threads on network.

-shay.banon

On Thu, Mar 4, 2010 at 7:45 PM, Sergio Bossa [sergio.bossa@gmail.com](mailto:sergio.bossa@gmail.com) wrote:

> On Thu, Mar 4, 2010 at 6:36 PM, Shay Banon [shay.banon@elasticsearch.com](mailto:shay.banon@elasticsearch.com)  
> wrote:
> 
> > One more note, because of the async nature of elasticsearch (completely  
> > async tcp for example),
> 
> Is it async meaning it doesn't wait for the indexing response? Or does  
> it rather wait by using some kind of continuation?
> 
> --  
> Sergio Bossa  
> [http://www.linkedin.com/in/sergiob](http://www.linkedin.com/in/sergiob)

---

<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:** [July 6, 2017, 4:25am UTC](https://discuss.elastic.co/t/elapsed-query-time/2836/13 "2017-07-06T04:25:28Z")

</div>


