就查了7条记录就要2秒钟,绝对不能忍,用内连接很快,为什么用左外连接就慢成蜗牛。
查询语句:
explain select * from (
select * from device where enterprise_id in (
select enterprise_id from user_enterprise where user_id = 1
)
) t1
left join (
select * from device_data
where device_data_id in ('139212', '139295', '142934', '142935')
) t2
using(device_id)
表结构:
explain结果: