# Setting timezone on date\_histogram slow down the query

**URL:** <https://discuss.elastic.co/t/setting-timezone-on-date-histogram-slow-down-the-query/194918>\
**Category:** Elasticsearch\
**Created:** [August 12, 2019, 8:26pm UTC](https://discuss.elastic.co/t/setting-timezone-on-date-histogram-slow-down-the-query/194918 "2019-08-12T20:26:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bertrand](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bertrand/32/45679_2.png) [@Bertrand](https://discuss.elastic.co/u/Bertrand)\
**Post date:** [August 12, 2019, 8:26pm UTC](https://discuss.elastic.co/t/setting-timezone-on-date-histogram-slow-down-the-query/194918/1 "2019-08-12T20:26:00Z")

</div>

Hi there,

It seems that setting the `timezone` option to a `date_histogram` has a negative effect on the query performance. Suppose the following query:

```auto
{
  "size": 0,
  "aggs": {
    "2": {
      "date_histogram": {
        "field": "@timestamp",
        "calendar_interval": "1d",
        "time_zone": "Europe/Brussels"
      }
    }
  },
  "query": {
    "bool": {
      "must": [
        {
          "range": {
            "@timestamp": {
              "format": "strict_date_optional_time",
              "gte": "2019-05-01T00:00:00.000Z",
              "lte": "2019-05-10T00:00:00.000Z"
            }
          }
        }
      ]
    }
  }
}

```

This query is executed on an alias targeting 10 indexes, each with 3 shards and 1 replica - all hosted on 3 different nodes and containing a total of 480M documents.

With timezone set, execution time is `16821ms`. Without timezone, the execution time goes down to `6920ms`.

Is this expected?  
Is there something I can do to optimize the setup and lower the execution time when timezone is set?

PS: this query is similar to what the Kibana Discover panel does when building the histogram...

---

<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:** [September 9, 2019, 8:26pm UTC](https://discuss.elastic.co/t/setting-timezone-on-date-histogram-slow-down-the-query/194918/2 "2019-09-09T20:26:00Z")

</div>

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