1万6千条数据left join 特别慢 求优化sql
0
现在有两张表大约都是1万6千条左右 2张表left join 执行后大约27秒很慢 求优化
select tt.id,tt.email,tt.mobilenum from (select t.id,t.email,t.mobilenum from tmp_table t) tt left join
(select u.id,u.email from hui_user u where u.meetid = 411) usr on tt.email = usr.email ;
数据库:Oracle
select tt.id,tt.email,tt.mobilenum from (select t.id,t.email,t.mobilenum from tmp_table t) tt left join
(select u.id,u.email from hui_user u where u.meetid = 411) usr on tt.email = usr.email ;
数据库:Oracle
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
3 个回复
老头子 - 专注是唯一的捷径 2015-11-01 回答
赞同来自: 安东尼奥
不过你不发执行计划,单看你的SQL,能给出的建议只有以下几点:
1. tmp_table 建立email + id + mobilenum 的组合索引
2. hui_user 建立email + id + meetid 索引
3. 去掉子查询
改写成:
select tt.id,tt.email,tt.mobilenum
from tmp_table tt
left join hui_user u
on tt.email = usr.email
and u.meetid = 411 ;
gogodiy - 天善智能数据库专家、Tableau爱好者 2015-11-02 回答
赞同来自:
seng - 从事BI、大数据、数据分析工作 2015-11-02 回答
赞同来自:
不过你的语句我也觉得很奇怪,为什么要用子查询啊,虽然不一定影响执行,但就是很怪啊。