# Slower geo\_distance queries in 2.2

**URL:** <https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655>\
**Category:** Elasticsearch\
**Created:** [February 12, 2016, 8:36pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655 "2016-02-12T20:36:09Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![PeteyPabPro](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PeteyPabPro](https://discuss.elastic.co/u/PeteyPabPro)\
**Post date:** [February 12, 2016, 8:36pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/1 "2016-02-12T20:36:09Z")

</div>

I've been using 2.1.1 for the last few months, and a couple days ago upgraded to 2.2.0. With 2.1.1, random continental-US geo\_distance queries were taking around 10 ms, with 2.2.0 they are taking more on the order of 150 ms. My test index is about 1.5M documents, all with the geo\_point field I am searching against.

I know 2.2.0 is supposed to be faster for geo\_point queries, so this is certainly confusing. Just wondering if anyone else was having this experience, or if anyone knew what might be going on. Let me know if any particular info would help.

---

<div class="post-metadata">

**Author:** ![nknize](https://avatars.discourse-cdn.com/v4/letter/n/edb3f5/32.png) [@nknize](https://discuss.elastic.co/u/nknize)\
**Post date:** [February 12, 2016, 9:03pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/2 "2016-02-12T21:03:20Z")

</div>

Greetings @PeteyPabPro

> random continental-US geo\_distance queries... My test index is about 1.5 documents

Can you be more clear? Are you seeing a drastic variance as a function of distance? location? 1.5 what? Thousand, Million? Are your documents multi-valued? Nested? Are you using Queries? Filters? Any additional information you can provide to replicate the performance difference would be helpful.

Thanks!

---

<div class="post-metadata">

**Author:** ![PeteyPabPro](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PeteyPabPro](https://discuss.elastic.co/u/PeteyPabPro)\
**Post date:** [February 12, 2016, 9:51pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/3 "2016-02-12T21:51:38Z")

</div>

Hi,

Sorry, meant 1.5 million documents (fixed above).

1. I'm not seeing much variance at all. 136 ms average, with a std dev of 18 over 200 random US lat/long searches.
2. The field I am filtering is not multi-valued; there are other multi-valued and object fields in the document (none nested, however).
3. I'm using filters.

I realize this would be hard in any sense to recreate, but really just wanted to see if anyone else was having the same issue.

---

<div class="post-metadata">

**Author:** ![jweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jweber/32/8437_2.png) [@jweber](https://discuss.elastic.co/u/jweber)\
**Post date:** [March 11, 2016, 6:31pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/4 "2016-03-11T18:31:52Z")

</div>

I've definitely encountered this issue as well and are able to recreate it with test data. The following comparisons were performed against v2.1.2, v2.2.0 and 5.0.0 (built from source).

The test data is 6 million documents with random locations on the following index (single shard, query cache disabled). I'm running Elasticsearch with the stock configs on my development machine.

```
{
  "test": {
    "mappings": {
      "document": {
        "properties": {
          "id": {
            "type": "integer"
          },
          "location": {
            "type": "geo_point",
            "lat_lon": true
          }
        }
      }
    }
  }
}

```

The `geo_distance` queries look like:

```
{
  "query": {
    "bool": {
      "filter": {
        "geo_distance": {
          "distance": "100mi",
          "location": "[lat], [lon]"
        }
      }
    }
  }
}

```

Here are the average times when performing the same 100 `geo_distance` searches against the different Elasticsearch versions:

```
Radius 2.1.2 2.2.0 5.0.0
1mi 256ms 1ms 2ms
10mi 206ms 10ms 2ms
30mi 236ms 36ms 3ms
50mi 252ms 277ms 40ms
100mi 258ms 461ms 74ms
250mi 241ms 2,088ms 315ms
500mi 227ms 3,534ms 643ms
1000mi 223ms 943ms 339ms
2000mi 280ms 754ms 683ms

```

I was also curious about bounding box performance, so I ran the same queries using a bounding box that circumbscribes the diameter of the `geo_distance` query:

```
            2.1.2 2.2.0 5.0.0
1mi 211ms 23ms 9ms
10mi 217ms 72ms 13ms
30mi 221ms 60ms 18ms
50mi 221ms 91ms 23ms
100mi 220ms 89ms 32ms
250mi 223ms 130ms 54ms
500mi 231ms 168ms 81ms
1000mi 231ms 156ms 96ms
2000mi 226ms 143ms 100ms

```

The slower queries for 2.2.0 and 5.0.0 always have the largest matching count of documents, so queries over areas with lower matching documents perform quickly.

I'm not too sure what to think about the v2.2.0 performance at 250mi and 500mi, but it's definitely not an option for us to run those searches. The next version looks to be an improvement over 2.2.0 but still lags behind 2.1.2 with regards to larger radius searches.

---

<div class="post-metadata">

**Author:** ![jweber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jweber/32/8437_2.png) [@jweber](https://discuss.elastic.co/u/jweber)\
**Post date:** [March 11, 2016, 6:50pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/5 "2016-03-11T18:50:05Z")

</div>

I also meant to mention that the average response times follow the same pattern overall even with a smaller set of documents (~500,000).

---

<div class="post-metadata">

**Author:** ![PeteyPabPro](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@PeteyPabPro](https://discuss.elastic.co/u/PeteyPabPro)\
**Post date:** [March 18, 2016, 2:52am UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/6 "2016-03-18T02:52:50Z")

</div>

Hi @jweber ,

Awesome analysis - thanks for putting this together. Do you think it's worth filing a bug report?

@nknize what do you think?

---

<div class="post-metadata">

**Author:** ![cdonnellytx](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/cdonnellytx/32/8603_2.png) [@cdonnellytx](https://discuss.elastic.co/u/cdonnellytx)\
**Post date:** [March 22, 2016, 2:37pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/7 "2016-03-22T14:37:19Z")

</div>

_(reposted from issue [16481](https://github.com/elastic/elasticsearch/issues/16481))_

Hi all,

We are also seeing poor performance with documents indexed on 2.2.1 (as opposed to a preexisting index created on 1.7.3 prior to upgrade).

It looks like this was closed because 2.3.0 was slated to be released sometime in February, but it's been over a month and 2.3.0 hasn't been released, nor can I find any documentation on when it will be released.

Is there a workaround on 2.2 where you can tell Elasticsearch to index using the old format? Or are the only workarounds the script / not upgrading at this time?

_(edited for formatting, bad URL)_

---

<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:** [July 5, 2017, 11:06pm UTC](https://discuss.elastic.co/t/slower-geo-distance-queries-in-2-2/41655/8 "2017-07-05T23:06:11Z")

</div>


