首页 > 数据库 > MySQL > 正文

mysql 字符集造成的功能问题

2024-07-24 12:35:19
字体:
来源:转载
供稿:网友
  简单的查询,返回同样的,用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,
 
  --  a.order_id = c.order_id
 
  a.charge_id = c.charge_id
 
  AND c.product_id = d. product_id;

(编辑:武林网)

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表