# Sorted index query time is same as unsorted index

**URL:** <https://discuss.elastic.co/t/sorted-index-query-time-is-same-as-unsorted-index/216228>\
**Category:** Elasticsearch\
**Created:** [January 23, 2020, 11:38am UTC](https://discuss.elastic.co/t/sorted-index-query-time-is-same-as-unsorted-index/216228 "2020-01-23T11:38:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![royal\_man](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/royal_man/32/67426_2.png) [@royal\_man](https://discuss.elastic.co/u/royal_man)\
**Post date:** [January 23, 2020, 11:38am UTC](https://discuss.elastic.co/t/sorted-index-query-time-is-same-as-unsorted-index/216228/1 "2020-01-23T11:38:16Z")

</div>

I have a sorted index based on `profile_created_time`.  
When I query to the index when **index sorting enabled** and **disabled**. Query time is same.

Can someone help what is wrong with my query.

```auto
{
  "size": 20,
  "from": 0,
  "sort": [
    {
      "profile_created_time": {
        "order": "desc"
      }
    }
  ],
  "query": {
    "bool": {
      "filter": {
        "bool": {
          "should": [
            {
              "friend": {
                "status": "online"
              }
            }
          ]
        }
      },
      "must": {
        "dis_max": {
          "queries": [
            {
              "bool": {
                "boost": 0.1,
                "must": {
                  "constant_score": {
                    "filter": {
                      "match_phrase": {
                        "name": {
                          "query": "andy"
                        }
                      }
                    }
                  }
                }
              }
            },
            {
              "simple_query_string": {
                "auto_generate_synonyms_phrase_query": false,
                "default_operator": "and",
                "fields": [
                  "name^0.000000",
                  "nickname^0.000000"
                ],
                "query": "andy"
              }
            }
          ],
          "tie_breaker": 0
        }
      }
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [January 23, 2020, 3:22pm UTC](https://discuss.elastic.co/t/sorted-index-query-time-is-same-as-unsorted-index/216228/2 "2020-01-23T15:22:53Z")

</div>

first, can you check that the index sort order is the same in the mapping?

second, you can use the [profile API](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/search-profile.html) - or to simplify things, use the [kibana profiler](https://www.elastic.co/guide/en/kibana/7.5/xpack-profiler.html), which leverages that API, to check where the time of your query is spent.

---

<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 20, 2020, 3:22pm UTC](https://discuss.elastic.co/t/sorted-index-query-time-is-same-as-unsorted-index/216228/3 "2020-02-20T15:22:54Z")

</div>

Closed on February 20, 2020, 3:22pm UTC

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