# Performance Impact of Index Sorting by Routing Key with Custom Sharding

**URL:** <https://discuss.elastic.co/t/performance-impact-of-index-sorting-by-routing-key-with-custom-sharding/380524>\
**Category:** Elasticsearch\
**Created:** [July 29, 2025, 8:57am UTC](https://discuss.elastic.co/t/performance-impact-of-index-sorting-by-routing-key-with-custom-sharding/380524 "2025-07-29T08:57:43Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dimitris\_Makris](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dimitris_makris/32/143346_2.png) [@Dimitris\_Makris](https://discuss.elastic.co/u/Dimitris_Makris)\
**Post date:** [July 29, 2025, 8:57am UTC](https://discuss.elastic.co/t/performance-impact-of-index-sorting-by-routing-key-with-custom-sharding/380524/1 "2025-07-29T08:57:43Z")

</div>

We have an Elasticsearch index where each document represents an employee, and each employee has an `account_id` field identifying the account they belong to. Our index uses 18 shards, and we’ve implemented custom routing based on the `account_id`, so all employees belonging to the same account are stored within the same shard.

We’re considering using the index sorting feature (`index.sort.field`), specifically sorting by `account_id`, and would like some advice:

**Would enabling index sorting by `account_id` help improve the performance of search requests to our index?**  
What are the potential benefits or drawbacks of sorting documents within each segment by `account_id` in a setup like ours, where routing already ensures account-based data locality? Are there specific query patterns or search scenarios where this would make a meaningful difference in performance?

Any best practices about combining custom routing with index sorting would be very helpful.
