Understanding how to choose between fields and tags in InfluxDB
23
votes
3
answers
39621
views
What are some good rules and examples of how to choose between storing data in fields vs. tags when designing [InfluxDB schemas](https://docs.influxdata.com/influxdb/v1.2/concepts/schema_and_data_layout/) ?
What I've [found so far](https://docs.influxdata.com/influxdb/v1.7/concepts/schema_and_data_layout/#encouraged-schema-design) is:
> a measurement that changes over time should be a field, and metadata about the measurement should be in tags
>
> tags and fields are effectively columns in the table. tags are indexed, fields are not
>
> the values that are highly variant and not usually part of a WHERE clause are put into fields
>
> Store data in fields if you plan to use them with an InfluxQL function
>
> Tags containing highly variable information like UUIDs, hashes, and random strings will lead to a large number of series in the database, known colloquially as high series cardinality. High series cardinality is a primary driver of high memory usage for many database workloads.
But let's say you store filled orders in an e-commerce application: order id, sale price, currency.
* Should the order id be a tag, or a field?
* Should the currency be a tag, or a field?
Asked by Dan Dascalescu
(331 rep)
Feb 6, 2017, 01:49 AM
Last activity: Apr 5, 2021, 03:26 PM
Last activity: Apr 5, 2021, 03:26 PM