# Field data types size

**URL:** <https://discuss.elastic.co/t/field-data-types-size/166389>\
**Category:** Elasticsearch\
**Created:** [January 30, 2019, 3:28pm UTC](https://discuss.elastic.co/t/field-data-types-size/166389 "2019-01-30T15:28:37Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gorek](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@gorek](https://discuss.elastic.co/u/gorek)\
**Post date:** [January 30, 2019, 3:28pm UTC](https://discuss.elastic.co/t/field-data-types-size/166389/1 "2019-01-30T15:28:38Z")

</div>

In documentation I found lot of fields datatypes supported by Elasticsearch but theres not information about how much storage each type consumes.

For example which datatype (keyword or ip) will be better for store IP address in index in case when we don't search it by CIDR?  
Difference is matters when we would like store hundred of thousand documents.

Where can I find how is each datatype size on storage?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 30, 2019, 3:31pm UTC](https://discuss.elastic.co/t/field-data-types-size/166389/2 "2019-01-30T15:31:00Z")

</div>

> [@gorek](#):
>
> theres not information about how much storage each type consumes

That's because it depends on a few things, like sparsity, size of the actual data.

> [@gorek](#):
>
> Where can I find how is each datatype size on storage?

Test it on your own data is the best option.

---

<div class="post-metadata">

**Author:** ![gorek](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@gorek](https://discuss.elastic.co/u/gorek)\
**Post date:** [January 31, 2019, 9:25am UTC](https://discuss.elastic.co/t/field-data-types-size/166389/3 "2019-01-31T09:25:41Z")

</div>

> [@warkolm](#):
>
> size of the actual data.

So if I choose integer as datatype and in one document I set this field as 12 and in other document set the same field as 1234 the sizes will be different? Interesting..

I know documents in indices are compressed so sparsity can affect to size on disk but I don't want to count storage requirements. I would like to know which datatype select for certain fields and don't waste storage if I really don't need some feature (like search by CIDR).

> [@warkolm](#):
>
> Test it on your own data is the best option.

I agree this is best option if You do this in your home not for customer where this data will be stored for months or even years.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [January 31, 2019, 9:28am UTC](https://discuss.elastic.co/t/field-data-types-size/166389/4 "2019-01-31T09:28:13Z")

</div>

> [@gorek](#):
>
> So if I choose integer as datatype and in one document I set this field as 12 and in other document set the same field as 1234 the sizes will be different? Interesting..

Dunno how you got that from my comment, it's not what I am saying.

An integer in Elasticsearch is fixed at 32 bits max. But a keyword can be any size. And if you have a document with a 4000 word keyword field then it's going to make an impact.

---

<div class="post-metadata">

**Author:** ![gorek](https://avatars.discourse-cdn.com/v4/letter/g/f08c70/32.png) [@gorek](https://discuss.elastic.co/u/gorek)\
**Post date:** [January 31, 2019, 10:01am UTC](https://discuss.elastic.co/t/field-data-types-size/166389/5 "2019-01-31T10:01:49Z")

</div>

As example I ask about difference between ip and keyword datatypes and you say it depend on size of actual data so I deduce that.

Let's start again. If I choose ip as datatype and I will only keep in this field IPv4 address it's better choice than keyword datatype, am I right?

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [January 31, 2019, 10:54am UTC](https://discuss.elastic.co/t/field-data-types-size/166389/6 "2019-01-31T10:54:38Z")

</div>

It is not quite that simple. When you index a keyword, the string is not stored once for every occurrence. The size on disk and in memory therefore depend on the cardinality of the field as well as the number of segments in the shard, as a dictionary holding keywords mapped to shorter ([global ordinals](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/eager-global-ordinals.html)) identifiers are kept per segment.

The easiest way to find out is therefore to test with as realistic data as you can find.

---

<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:** [February 28, 2019, 10:54am UTC](https://discuss.elastic.co/t/field-data-types-size/166389/7 "2019-02-28T10:54:44Z")

</div>

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