InfluxDB: store data in a single measurement

2019-08-25 08:08发布

问题:

InfluxDB ideal way of storing data looks like the following:

* temperature
timestamp,iotid,value
----------------------------
1501230195,iot1,70

* humidity
timestamp,iotid,value
-------------------------
1501230195,iot1,45

* pressure
timestamp,iotid,value
-------------------------
1501230195,iot1,850

How bad is to store data in a single measurement like so?

* data
timestamp,iotid,measure,value
----------------------------
1501230195, iot1, temperare, 70
1501230195, iot1, humidity, 45
1501230195, iot1, pressure, 850

My problem is that I would also need to query the log from date x to date y of all my measures ordered by timestamp, but I can't do it using separate measurements.

回答1:

There is no ideal/recommended way for this question according official doc: https://docs.influxdata.com/influxdb/v1.7/concepts/schema_and_data_layout/. It depends on the use case. Your case makes sense to keep data in one measurement, because they have the same tags, they share also tag values with nice low cardinality + you will have mentioned query issue with multiple measurements.

I have single measurement design in production with ~250M data points (multi node cluster with sharding) and no problem with performance.



标签: influxdb