1

关于批量插入的性能。
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更友好?

4

1 回答 1

0

对于您的样品,性能几乎相同,以获得更好的性能,您应该使用像这样的真正的 bacth 插入物

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, ...), ...

在此示例中,插入解析的数量对您的示例来说是次要的..

于 2015-11-30T12:12:07.557 回答