当前位置:网站首页>mysql 连接查询在on中使用convert 导致扫描行数增长
mysql 连接查询在on中使用convert 导致扫描行数增长
2022-07-22 10:52:00 【BUG胡汉三】
因为表前期设计问题,导致要连接的两张表的主外键类型不一致.但是在生产库上已经调整为一致了,测试库没有调整.开发时Navicat美化sql会自动帮忙加上convert(`d`.`id` using utf8mb4)字样.不小心把这个sql复制到生产了.于是导致了sql变慢.
加上了convert转换的解释结果:
1 PRIMARY <derived2> ALL 102899300 Using filesort
2 DERIVED a ALL 8
2 DERIVED u eq_ref PRIMARY PRIMARY 8 a.user_id 1
3 DEPENDENT SUBQUERY o ALL 710 Using where
4 UNION v ALL 491
4 UNION u eq_ref PRIMARY PRIMARY 8 v.members_user_id 1
4 UNION m eq_ref PRIMARY PRIMARY 8 v.merchants_id 1
4 UNION d ALL 105214 Using where; Using join buffer (Block Nested Loop)
5 DEPENDENT SUBQUERY o ALL 710 Using where
6 UNION s ALL 487
6 UNION u eq_ref PRIMARY PRIMARY 8 s.user_id 1
6 UNION m eq_ref PRIMARY PRIMARY 8 s.merchants_id 1
6 UNION d ALL 105214 Using where; Using join buffer (Block Nested Loop)
7 DEPENDENT SUBQUERY o ALL 710 Using where
UNION RESULT <union2,4,6> ALL Using temporary
去掉的解释结果:
1 PRIMARY <derived2> ALL 986 Using filesort
2 DERIVED a ALL 8
2 DERIVED u eq_ref PRIMARY PRIMARY 8 a.user_id 1
3 DEPENDENT SUBQUERY o ALL 710 Using where
4 UNION v ALL 491
4 UNION u eq_ref PRIMARY PRIMARY 8 v.members_user_id 1
4 UNION m eq_ref PRIMARY PRIMARY 8 v.merchants_id 1
4 UNION d eq_ref PRIMARY PRIMARY 202 m.dp_id 1
5 DEPENDENT SUBQUERY o ALL 710 Using where
6 UNION s ALL 487
6 UNION u eq_ref PRIMARY PRIMARY 8 s.user_id 1
6 UNION m eq_ref PRIMARY PRIMARY 8 s.merchants_id 1
6 UNION d eq_ref PRIMARY PRIMARY 202 m.dp_id 1
7 DEPENDENT SUBQUERY o ALL 710 Using where
UNION RESULT <union2,4,6> ALL Using temporary
这里可以看到<derived2>的差别巨大,本来一个很小很小的应用,没有多少数据,加上convert后,居然会扫描出102899300上亿行的数据.
可能是因为convert是针对字符集的转换.那么会导致每一个字符算作一行数据.当然这只是一个猜想.
边栏推荐
- postman接口测试
- Airtest test framework construction
- Constructive common centroid placement and routing of binary weighted capacitor arrays
- 多线程05--Lock
- Automatic current mirror layout (acml) tool
- Bash变量--位置参数变量
- 【FPGA】:ip核--rapid io
- 动态规划入门
- Common centroid layout of active and passive equipment: review and future road
- pycharm设置
猜你喜欢
Wechat applet cannot read property'setdata'of null error
Pytest testing framework built quickly
Session和Cookie的关系与区别
ASP.NET Core部署手册:4.注意事项和问题排查
二元加权电容器阵列的构造性共质心布局与布线
多线程03--synchronized和锁升级
Redis series 13 -- redis Sentinel
Automatic current mirror layout (acml) tool
Automatic generation of common centroid capacitance array with arbitrary capacitance ratio
Wiring ability of twisted common centroid capacitor array under signal coupling constraints
随机推荐
面试官:生成订单30分钟未支付,则自动取消,该怎么实现?
APP专项测试
【FPGA】状态机
测试相关基础概念
Bash基本功能—通配符和其他特殊符号
多线程04--线程的原子性、CAS
【FPGA】:ip核--rapid io
Bash变量—数值运算与运算符
Highly configurable and scalable spiral capacitor design for high-density or high-precision applications
Using various weighting methods to place binary weighted capacitor array in SAR ADC
Commonly used operators of spark
弱网测试(Charles模拟)
Multithreading 02 -- sequential execution and stop of threads
Redis 系列13--Redis 哨兵
Django中使用Mysql数据库
Multithread 07 -- ThreadLocal
Common centroid capacitor layout generation considering device matching and parasitic minimization
【FPGA】:ip核-DDS
顺序表的创建插入和修改
ETL过程