# Slow performance of shape query

**URL:** <https://discuss.elastic.co/t/slow-performance-of-shape-query/252158>\
**Category:** Elasticsearch\
**Created:** [October 15, 2020, 9:09am UTC](https://discuss.elastic.co/t/slow-performance-of-shape-query/252158 "2020-10-15T09:09:49Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![inomad](https://avatars.discourse-cdn.com/v4/letter/i/5f9b8f/32.png) [@inomad](https://discuss.elastic.co/u/inomad)\
**Post date:** [October 15, 2020, 9:09am UTC](https://discuss.elastic.co/t/slow-performance-of-shape-query/252158/1 "2020-10-15T09:09:49Z")

</div>

I am using Shape field type to store multi-point 2D trajectory paths (LINESTRING). All coordinates are normalized to the range [0..1].

And it seems that query performance (say search for intersection with 2-point line) is quite slow - it looks like a hotspot in profiler. As an example: if I add Shape query which matches almost all objects filtered by other filter clauses, query time increases from 3-5ms to 50-450ms. And it looks like size does not affect the time - it can be 10 or 5000 - does not matter - seems like it checks every potentially suitable document.

Some context: Elastic 7.9.2, all clauses are filters of Bool query, query has sorting (the same as index order).

I suspect this is because of [0..1] scale, but I'm unable to find any details about it.

**UPDATE**  
After I scaled coordinates to integer values request time become ~40% less.  
Then I _forcemerge_ index and it looks like shape query start using caching more aggressively - ES reports 2-5ms of search time. But profiler still shows that shape query is a bottleneck (~300ms).

Can long trajectory (tens of points) be a cause?

---

<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 12, 2020, 9:10am UTC](https://discuss.elastic.co/t/slow-performance-of-shape-query/252158/2 "2020-11-12T09:10:05Z")

</div>

Closed on November 12, 2020, 9:10am UTC

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