# Slow Query Performance

**URL:** <https://discuss.elastic.co/t/slow-query-performance/6558>\
**Category:** Elasticsearch\
**Created:** [February 1, 2012, 1:07am UTC](https://discuss.elastic.co/t/slow-query-performance/6558 "2012-02-01T01:07:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brian\_Seagraves](https://avatars.discourse-cdn.com/v4/letter/b/f05b48/32.png) [@Brian\_Seagraves](https://discuss.elastic.co/u/Brian_Seagraves)\
**Post date:** [February 1, 2012, 1:07am UTC](https://discuss.elastic.co/t/slow-query-performance/6558/1 "2012-02-01T01:07:40Z")

</div>

Hello, I'm having some trouble getting some queries to perform well.

Info:

9,000,000 places with lat/lon  
AWS EC2 m1.large instance  
ES\_MAX\_MEM = ES\_MIN\_MEM = 5g  
bootstrap.mlockall: true  
ulimit -l unlimited

Using a geodistance filter, it takes 9 seconds and change consistently  
to return a result set. It did this before upping the default memory  
allocation too. How can I make this faster?

Thanks for the help,  
Brian Seagraves

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [February 1, 2012, 10:06am UTC](https://discuss.elastic.co/t/slow-query-performance/6558/2 "2012-02-01T10:06:45Z")

</div>

First, make sure you execute it several times before you start to analyzer the response time.

What is the query that you execute? Is it a match all on all the docs and filter by distance? The computation (by default) is quite CPU intensive, since the values are loaded into memory and then a bbox is computed to be checked, and then the distance is calculated. You have several options to make it faster:

1. Use a different distance calculation ([Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html), under options, setting distance\_type to plane).
2. Use optimize\_bbox set to indexed (the default is memory). For that though, you will need to enable specific lat lon indexing in the geo\_type mapping (and reindex).
3. Have a stronger machine / more machines with a bit more CPUs than the AWS large instance which is as strong as a laptop I had 5 years ago, and thats not without noisy neighbors.

On Wednesday, February 1, 2012 at 3:07 AM, Brian Seagraves wrote:

> Hello, I'm having some trouble getting some queries to perform well.
> 
> Info:
> 
> 9,000,000 places with lat/lon  
> AWS EC2 m1.large instance  
> ES\_MAX\_MEM = ES\_MIN\_MEM = 5g  
> bootstrap.mlockall: true  
> ulimit -l unlimited
> 
> Using a geodistance filter, it takes 9 seconds and change consistently  
> to return a result set. It did this before upping the default memory  
> allocation too. How can I make this faster?
> 
> Thanks for the help,  
> Brian Seagraves

---

<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 6, 2017, 3:40am UTC](https://discuss.elastic.co/t/slow-query-performance/6558/3 "2017-07-06T03:40:52Z")

</div>


