5. 性能优化
写入接口选择 Session > JDBC
Session.insertRecords> Session.insertRecord
最灵活、通用
Session.InsertTablets > Session.InsertTable
接口执行效率最高
格式限制较强,需注意客户端格式转化耗时
device1
insertTablet
time s1 s2 s3
1 a b c
2 a b c
3 a b c
device1
insertRecords
time s1 s2 s3
1 a
2 b
3 c
6. 性能优化
避免乱序
Kafka Topic 内部按照设备 ID 分区、尽量保证每个设备的
数据都在一个分区内,时间戳递增
同一个设备数据尽量按时间戳递增写入
无乱序
insert into root.sg.d1(timestamp,s1,s2) values(1,1,1)
insert into root.sg.d1(timestamp,s1,s2) values(2,1,2)
可能产生乱序
insert into root.sg.d1(timestamp,s1) values(1,1)
insert into root.sg.d1(timestamp,s2) values(1,2)
insert into root.sg.d1(timestamp,s1) values(2,1)
insert into root.sg.d1(timestamp,s2) values(2,2)
可能产生乱序
insert into root.sg.d1(timestamp,s1,s2) values(2,1,2)
insert into root.sg.d1(timestamp,s1,s2) values(1,1,2)
Time s1 s2
1 1 2
2 1 2