# Does it make sense to add timestamp in "index sorting"?

**URL:** <https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551>\
**Category:** Elasticsearch\
**Created:** [October 12, 2021, 10:28pm UTC](https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551 "2021-10-12T22:28:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [October 12, 2021, 10:28pm UTC](https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551/1 "2021-10-12T22:28:00Z")

</div>

The documentation suggests using low cardinality field(s) for index sorting.  
We often search documents with some low cardinality ID (like site or org) and then with timestamp.  
Does it make sense to include timestamp in the mix?  
I am paying a little bit overhead for the write with "index sorting". If I can't get much out of it, I will remove timestamp to gain back the write performance.

Any suggestions will be highly appreciated.

---

<div class="post-metadata">

**Author:** ![mayya](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mayya/32/83147_2.png) [@mayya](https://discuss.elastic.co/u/mayya)\
**Post date:** [October 13, 2021, 11:45am UTC](https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551/2 "2021-10-13T11:45:55Z")

</div>

Index sorting on a field is good for 2 things: to reduce disk usage and speed up queries with `sort` on this field. Disk space is reduced because we can efficiently compress the same values, but this would not help `timestamp` field, as I expect this field will have all unique values. So there are no benefits here for `timestamp` field.  
You can speed up sort queries but only in one direction, if your index is sorted by `timestamp` desc, only these queries with sort `timestamp` desc will be faster, queries on `timestamp` asc will not be.

Moreover, in the newer version of Elasticsearch, we have implemented automatic sort optimizations on `timestamp` field both asc and desc, so you don't need index sorting there as well, sort queries on `timestamp` should be quite fast.

---

<div class="post-metadata">

**Author:** ![linkerc](https://avatars.discourse-cdn.com/v4/letter/l/13edae/32.png) [@linkerc](https://discuss.elastic.co/u/linkerc)\
**Post date:** [October 13, 2021, 6:05pm UTC](https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551/3 "2021-10-13T18:05:05Z")

</div>

Thanks. I will remove it for our deployment.

---

<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:** [November 10, 2021, 6:05pm UTC](https://discuss.elastic.co/t/does-it-make-sense-to-add-timestamp-in-index-sorting/286551/4 "2021-11-10T18:05:21Z")

</div>

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