# Performance degradation when using Date field in epoch millis vs date values stored as long numbers

**URL:** <https://discuss.elastic.co/t/performance-degradation-when-using-date-field-in-epoch-millis-vs-date-values-stored-as-long-numbers/261773>\
**Category:** Elasticsearch\
**Created:** [January 21, 2021, 11:53am UTC](https://discuss.elastic.co/t/performance-degradation-when-using-date-field-in-epoch-millis-vs-date-values-stored-as-long-numbers/261773 "2021-01-21T11:53:16Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Varsha\_Meghana](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/varsha_meghana/32/82667_2.png) [@Varsha\_Meghana](https://discuss.elastic.co/u/Varsha_Meghana)\
**Post date:** [January 21, 2021, 11:53am UTC](https://discuss.elastic.co/t/performance-degradation-when-using-date-field-in-epoch-millis-vs-date-values-stored-as-long-numbers/261773/1 "2021-01-21T11:53:16Z")

</div>

Hi, we are migrating to Elastic search 7.x from ES 1.7

We were storing various date values as long numbers (milliseconds) in our Elastic 1.7 server.  
However, we would want to move to ES 7.x and decided to make use of "date" field provided by ES 7.x , with format as "epoch\_millis".

While comparing the performance of sort queries on above mentioned changes, I see that the dates stored as long numbers in ES 1.7 are retrieved 3x times faster than dates stored as "date type" with epoch\_millis format. Both the ES 1.7 and ES 7.x servers have similar hardware capacities.

Could someone provide inputs on why the performance degraded? Below is the result!

ES 1.7

Mapping

```
postTimeMs" : {
            "type" : "long",
            "doc_values" : true
          }

```

 ![Screenshot 2021-01-21 at 5.16.39 PM](https://us1.discourse-cdn.com/elastic/original/3X/6/4/640cac3dd3fb77f6b1594ca392b90f82f3a82bb5.png)

ES 7.x

Mapping

```
 "post_date":{
           "type":"date",
           "format": "epoch_millis",
           "doc_values" : true
        },

```

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/8/d/8d3e44b7a269f6cc4afc8f9aad07c8607a1e2ab2.png)

---

<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:** [February 18, 2021, 11:53am UTC](https://discuss.elastic.co/t/performance-degradation-when-using-date-field-in-epoch-millis-vs-date-values-stored-as-long-numbers/261773/2 "2021-02-18T11:53:28Z")

</div>

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