# How to get the execution time of ES Sql query?

**URL:** <https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [June 10, 2021, 7:30am UTC](https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525 "2021-06-10T07:30:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Resington\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/resington_r/32/85143_2.png) [@Resington\_R](https://discuss.elastic.co/u/Resington_R)\
**Post date:** [June 10, 2021, 7:30am UTC](https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525/1 "2021-06-10T07:30:50Z")

</div>

Hi.. Can anyone please tell me how to get the execution time ( "took") for this below query. Thanks in advance...

```auto
async function mysqlfunc(req, res) {  
    client.transport.request({
        method: "POST",
        path: "/_sql",
        body: {
            query: "SELECT field1, filed2 FROM myindex limit 10"
        }
    }, function(error, response) {
        if (error) {
            console.error('Something does not compute : ' + error);
        } else {           
            console.log("Output : " + response.rows);
            res.send(response.rows);
        }
    });
}

```

---

<div class="post-metadata">

**Author:** ![matriv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/matriv/32/43656_2.png) [@matriv](https://discuss.elastic.co/u/matriv)\
**Post date:** [June 14, 2021, 2:00pm UTC](https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525/2 "2021-06-14T14:00:24Z")

</div>

You have to extract `Took-nanos` from the header of the HTTP response.

---

<div class="post-metadata">

**Author:** ![Resington\_R](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/resington_r/32/85143_2.png) [@Resington\_R](https://discuss.elastic.co/u/Resington_R)\
**Post date:** [June 15, 2021, 5:18am UTC](https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525/3 "2021-06-15T05:18:13Z")

</div>

Thanks a lot Matriv 👍

---

<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 13, 2021, 5:18am UTC](https://discuss.elastic.co/t/how-to-get-the-execution-time-of-es-sql-query/275525/4 "2021-07-13T05:18:32Z")

</div>

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