两种方式进行批量插入,性能是否相同



关于批量插入的性能
1.

insert goods(...) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods(...) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
...

2.

insert goods(...) values(...)
insert goods(...) values(...)
...
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)
insert goods_price(goods_id, level, price) values(...)

关于以上两种方式的性能相同还是不相同?哪种方式对mysql更友好?

对于您的示例,性能实际上是相同的为了获得更好的性能,你应该使用像这样的真正的细菌插入物

insert goods(...) values(v1, v2, v3...), (v1, v2, v3...), (v1, v2, v3...), ...
insert goods_price(goods_id, level, price) values(p1, p2,p3, ...), (p1, p2,p3, ...), (p1, p2,p3, ...), ...

在这个示例中,插入解析的数量与您的示例相比微不足道。。

相关内容

  • 没有找到相关文章

最新更新