# Does enabling hash on datatype ip - speed up response on cardinality aggr?

**URL:** <https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676>\
**Category:** Elasticsearch\
**Created:** [April 12, 2019, 4:41pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676 "2019-04-12T16:41:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anindya\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anindya_roy/32/43317_2.png) [@Anindya\_Roy](https://discuss.elastic.co/u/Anindya_Roy)\
**Post date:** [April 12, 2019, 4:41pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676/1 "2019-04-12T16:41:05Z")

</div>

It makes sense to turn on hash on fields whose datatype is string, to speed up response time of cardinality aggr as per [https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3.html](https://www.elastic.co/guide/en/elasticsearch/plugins/current/mapper-murmur3.html)

Wondering if there will be any performance improvement by turning on hash on the field whose datatype is 'ip' ? ( ip addresses )  
Wondering if distinct ip count is already treated as a integer.

Also, does the hash performed on the **field** represents a running total on the distinct values for that **field** seen from beginning of data in the index ?  
E.g. say we saw 100 distinct value for a particular **field** in the first hour and then another 50 distinct values in the next hour. When I run cardinality aggr query with a range filter to query the last 30 mins, i only expect to see 50 and not 150 + 50 = 200.

---

<div class="post-metadata">

**Author:** ![Anindya\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anindya_roy/32/43317_2.png) [@Anindya\_Roy](https://discuss.elastic.co/u/Anindya_Roy)\
**Post date:** [April 15, 2019, 6:22pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676/2 "2019-04-15T18:22:26Z")

</div>

my apologies if this is a repeat question that may have been discussed in the past.  
Any comments or thoughts @Mark_Harwood ?

---

<div class="post-metadata">

**Author:** ![Mark\_Harwood](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mark_harwood/32/10538_2.png) [@Mark\_Harwood](https://discuss.elastic.co/u/Mark_Harwood)\
**Post date:** [April 15, 2019, 8:21pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676/3 "2019-04-15T20:21:51Z")

</div>

> [@Anindya\_Roy](#):
>
> It makes sense to turn on hash on fields whose datatype is string,

The docs there give the example of long strings and I see that might apply to the use case of finding exact duplicates of texts. IP addresses are much smaller and so less likely to benefit from this technique.

> [@Anindya\_Roy](#):
>
> Also, does the hash performed on the **field** represents a running total on the distinct values

No.

---

<div class="post-metadata">

**Author:** ![Anindya\_Roy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/anindya_roy/32/43317_2.png) [@Anindya\_Roy](https://discuss.elastic.co/u/Anindya_Roy)\
**Post date:** [April 15, 2019, 9:21pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676/4 "2019-04-15T21:21:13Z")

</div>

Thanks a lot

---

<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:** [May 13, 2019, 9:21pm UTC](https://discuss.elastic.co/t/does-enabling-hash-on-datatype-ip-speed-up-response-on-cardinality-aggr/176676/5 "2019-05-13T21:21:19Z")

</div>

Closed on May 13, 2019, 9:21pm UTC

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