select count(*) as cnt
from igt_document a,igt_docfolder b,igt_log c
where a.doc_yearmon=b.doc_yearmon and b.userlog_id=c.userlog_id
and a.doc_number=b.doc_number
and (c.userlog_type='3' or (c.userlog_type='6' and a.fax_page=1))
and b.folder_date> (sysdate-7)
and c.userlog_id not in ('유우머','01011','010112','0101113')
and a.doc_type='4';
select count(*) as cnt
from igt_document a,igt_docfolder b,
(select userlog_type,userlog_id
from gt_log where not in ('유우머','01011','010112','0101113')) c
where a.doc_yearmon=b.doc_yearmon and b.userlog_id=c.userlog_id
and a.doc_number=b.doc_number
and (c.userlog_type='3' or (c.userlog_type='6' and a.fax_page=1))
and b.folder_date> (sysdate-7)
and a.doc_type='4';
이렇게 바꾸면..아마.빠를것 같는데용~~~^^
subquery로 바꾸시면..아마 빠를것 같군요..
그리고 sysdate-7같는 경우는 index를 이용하려면..
미리 변수를 지정하새..
v_date=sysdate-7;로..
지정한다음.
and b.folder_date> v_date
이렇게 하는것도 좋은 방법입니다..
도움이 되시기를.
|