与MariaDB相比,XDB2.0在Python客户机上的写入性能较慢

与MariaDB相比,XDB2.0在Python客户机上的写入性能较慢,mariadb,benchmarking,influxdb,influxdb-python,Mariadb,Benchmarking,Influxdb,Influxdb Python,我是InfluxDB的新手,我正在尝试比较MariaDB和InfluxDB 2.0的性能。因此,我执行了一个大约350.000行的基准测试,这些行存储在一个txt文件(30mb)中 在使用MariaDB时,我使用“executemany”将多行写入数据库,所有行(使用Python)大约需要20秒 因此,我使用Python客户机对XDB进行了同样的尝试,下面是我如何实现这一点的主要步骤 #Configuring the write api write_api = client.write_api(

我是InfluxDB的新手,我正在尝试比较MariaDB和InfluxDB 2.0的性能。因此,我执行了一个大约350.000行的基准测试,这些行存储在一个txt文件(30mb)中

在使用MariaDB时,我使用“executemany”将多行写入数据库,所有行(使用Python)大约需要20秒

因此,我使用Python客户机对XDB进行了同样的尝试,下面是我如何实现这一点的主要步骤

#Configuring the write api
write_api = client.write_api(write_options=WriteOptions(batch_size=10_000, flush_interval=5_000))

#Creating the Point
p = Point(“Test”).field(“column_1”,value_1).field(“column_2”,value_2) #having 7 fields in total

#Appending the point to create a list
data.append(p)

#Then writing the data as a whole into the database, I do this after collecting 200.000 points (this had the best performance), then I clean the variable “data” to start again
write_api.write(“bucket”, “org”, data)
执行此操作时,大约需要40秒,这是MariaDB时间的两倍

这个问题困扰了我很长一段时间,因为文档建议我分批编写,理论上应该比MariaDB快

但我可能错过了什么


提前谢谢你

将20MB的任何内容装载到磁盘上都需要一些时间

executemany
可能进行批处理。(我不知道细节。)

听起来XDB并没有做得那么好

要将大量数据放入表中,请执行以下操作:

  • 给定CSV文件,
    加载数据填充
    是最快的。但是如果您必须首先创建该文件,它可能不会赢得比赛
  • “批处理”
    插入速度非常快:
    插入。。。100行的值(1,11),(2,22),…
    ,其运行速度大约是单行
    插入的10倍。超过100行左右,它就会进入“收益递减”
  • 将单独的
    插入到“事务”中可以避免事务开销。(还有“回报递减”。)
用户和数据库之间有一百个包;XDB是另一个。我不知道细节