mysql中查询 in()参数太多, 导致查询很慢, 使用join优化。
在实例中in查询话费2s, 优化后0.4s
SELECT * from A
LEFT JOIN B ON A.B_ID = B.ID
where B.uuid in (001,002,003....)
优化后
SELECT * from A
INNER JOIN (
select id from B where uuid = 001
union
select id from B where uuid = 002
union
select id from B where uuid = 003 ....
) B on A.B_id = B.id
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)