mysql 字符集造成的性能问题
简单的查询,返回同样的,用charge_id去关联,只要0.5s,但如果用order_id要18s! 什么原因?
用order_id时,执行计划是用了Using join buffer (Block Nested Loop);原因查明:把order_forInit里的order_id字符集是utf8,而order_item_forInit里的order_id字符集是utf8mb4, 不同的字符集造成两个做join时,不能用上索引,会出现“Using join buffer (Block Nested Loop)”。把order_forInit里的order_id字符集改成utf8mb4,就没性能问题了!! 不会出现Using join buffer (Block Nested Loop)
explain
select count(*) from
order_forInit a,
order_item_forInit c,
product d
WHERE
-- a.order_id = c.order_id
a.charge_id = c.charge_id
AND c.product_id = d.product_id;
附录:
mysql字符集 utf8 和utf8mb4 的区别: https://blog.csdn.net/qq_37054881/article/details/90023611
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。