# Lower precision\_threshold in cardinality takes more time than higher

**URL:** <https://discuss.elastic.co/t/lower-precision-threshold-in-cardinality-takes-more-time-than-higher/326063>\
**Category:** Elasticsearch\
**Created:** [February 21, 2023, 11:56am UTC](https://discuss.elastic.co/t/lower-precision-threshold-in-cardinality-takes-more-time-than-higher/326063 "2023-02-21T11:56:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maya\_Simhi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/maya_simhi/32/117115_2.png) [@Maya\_Simhi](https://discuss.elastic.co/u/Maya_Simhi)\
**Post date:** [February 21, 2023, 11:56am UTC](https://discuss.elastic.co/t/lower-precision-threshold-in-cardinality-takes-more-time-than-higher/326063/1 "2023-02-21T11:56:20Z")

</div>

Hi,  
I'm using cardinality aggregation as a sub aggregation inside a term aggregation.  
I read a lot of explanations from Elasticsearch that says the higher the precision\_threshold the more time the query takes. but I see the exact opposite. if I send query with precision\_threshold 100 the query takes more than 28 sec, but if I send the exact same query with precision\_threshold 500 the query takes 4 sec  
this is the query I'm sending:

```auto
{"aggregations": {"sourceGrid": {"aggregations": { "bucket_sort": {"bucket_sort": {"from": 0,"size": 100}},"attributeCount": {"cardinality": {"field": "attribute.keywordWithoutLowercaseNormalizer", "precision_threshold": 100}}},"terms": {"field": "source.keywordWithoutLowercaseNormalizer", "size": 100}}},"size": 0}

```

I don't understand why is this happening, what number of precision\_threshold is the best for the best performance?

---

<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:** [March 21, 2023, 11:56am UTC](https://discuss.elastic.co/t/lower-precision-threshold-in-cardinality-takes-more-time-than-higher/326063/2 "2023-03-21T11:56:44Z")

</div>

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