我使用influxdb在我的项目,我面临的查询问题时,多点同时influxdb:写多点VS单点多次
写我使用influxdb的Python写Influxdb有1000个独特点。
在influxdb的Python有一个叫influxclient.write_points()
功能我现在有两个选择:
- 写的每一个时间(1000次)或
- 巩固1000点,写各点一次所有的点一次。
第一个选项的代码如下所示(仅仅是伪代码)和它的作品:
SELECT * FROM "mydb"
:
thousand_points = [0...9999
while i < 1000:
...
...
point = [{thousand_points[i]}] # A point must be converted to dictionary object first
influxclient.write_points(point, time_precision="ms")
i += 1
写所有的点,当我写这样的查询后,我得到所有1000分。
为了避免在每次迭代中每次写入所增加的开销,我感觉就像探索一次写多个点一样。 write_points
功能支持哪一种。
write_points(点,time_precision =无,数据库=无, retention_policy =无,标签=无,= batch_size时无)
写入多个时间序列的名字。
参数:点(字典的名单,每个字典代表 点) - 要写入数据库
所以点的名单,我所做的就是:
thousand_points = [0...999]
points = []
while i < 1000:
...
...
points.append({thousand_points[i]}) # A point must be converted to dictionary object first
i += 1
influxclient.write_points(points, time_precision="ms")
随着这个变化,当我查询:
SELECT * FROM "mydb"
我只得到1分作为结果。我不明白为什么。
任何帮助将不胜感激。
您可以添加一个单点的示例吗?我怀疑你是在没有指定时间戳的情况下将所有内容写入单个系列。 –