Mysql的批量插入有两种
第一种:
把一条insert循环1000次,其实际上还是单条插入,算不上批量插入。
insert into device445(id,tag456,tag22,tag123,created_time) values ("bc83b61f-3c57-43f8-a685-65c297f8dc66","3268","3268","3268","2021-02-09 10:41:03.081")
insert into device445(id,tag456,tag22,tag123,created_time) values ("bc83b61f-3c57-43f8-a685-65c297f8dc66","3268","3268","3268","2021-02-09 10:41:03.081")
看一下时间 1000条数据插入,144s!
第二种:
一条insert,后边所有的数据都跟在insert后面。
insert into device445(id,tag456,tag22,tag123,created_time) values ("bc83b61f-3c57-43f8-a685-65c297f8dc66","3268","3268","3268","2021-02-09 10:41:03.081"),("bc83b61f-3c57-43f8-a685-65c297f8dc66","3268","3268","3268","2021-02-09 10:41:03.081")
看一下时间 1000条数据插入,只要0.几秒,不到1s!
速度是不是快了上百倍!!
有问题欢迎留言讨论,不定时回复!
,