有如下sql语句:select count(1)
from t_project_one_estimate t
where exists (select t1.statistic_id
from t_project_one_estimate t1
where t1.statistic_close_state = 2);表t_project_one_estimate现在有一千多万条数据,每条数据都有状态,现在要查询是否存在状态为2的,如果存在就可以返回了,我写了如上sql语句但是查询速度很慢,现在请问下各位大哥,怎么优化下才能提升效率啊,或者其它方法也可以,小弟先谢谢各位了。只要说的有道理就给分。
from t_project_one_estimate t
where exists (select t1.statistic_id
from t_project_one_estimate t1
where t1.statistic_close_state = 2);表t_project_one_estimate现在有一千多万条数据,每条数据都有状态,现在要查询是否存在状态为2的,如果存在就可以返回了,我写了如上sql语句但是查询速度很慢,现在请问下各位大哥,怎么优化下才能提升效率啊,或者其它方法也可以,小弟先谢谢各位了。只要说的有道理就给分。
from dual
where exists (select 1
from t_project_one_estimate t1
where t1.statistic_close_state = 2);
where t1.statistic_close_state = 2
and rownum = 1;
from t_project_one_estimate t1
where t1.statistic_close_state = 2 and rownum=1
会不会好点?
照LZ的意思 是不是直接 select 1
from t_project_one_estimate
where statistic_close_state = 2就行了?
‘ilovemk’哥(姐)你 说说。。