今天项目中遇到一条sql语句,其中t_userdownreslog表数据4千万条,t_userinfo 数据2千万条.
修改前
修改后
多了个,/*+FIRST_ROWS*/
修改前
select t.user_account username,
t.mobile usermobile,
t.user_id userid,
u.down_type downtype,
u.resourceid appid,
u.resourcename appname,
u.package_id jarid
from t_userdownreslog u,t_userinfo t
where u.transaction_id = '10111902201098785862'
and t.user_id = u.user_id
and u.down_status=2
and u.tran_type=2;
修改后
select /*+FIRST_ROWS*/
t.user_account username,
t.mobile usermobile,
t.user_id userid,
u.down_type downtype,
u.resourceid appid,
u.resourcename appname,
u.package_id jarid
from t_userdownreslog u,t_userinfo t
where u.transaction_id = '10111902201098785862'
and t.user_id = u.user_id
and u.down_status=2
and u.tran_type=2;
多了个,/*+FIRST_ROWS*/
本文介绍了一条涉及大量数据的SQL查询语句优化案例。通过增加/*+FIRST_ROWS*/提示符改进了从两个大表中筛选数据的过程,提高了查询效率。
649

被折叠的 条评论
为什么被折叠?



