一个关于全表扫描的问题,急急急急急急急
我这里有个SQL语句
Select 1
from
fconsign c,
csubchargeitem s,
ccustsuppview csv,
cuser cu1,
cuser cu2,
fexpense e
where (e.fexp_creator = ? or exists (select 1 from FCONSIGN f where e.FEXP_CONSIGN_ID=f.FCSG_CONSIGN_ID and f.FCSG_CREATOR = ?))
and e.fexp_consign_id = c.fcsg_consign_id(+)
and e.fexp_charge_id = s.csci_ci_id(+)
and e.fexp_settlerment_object = csv.accountNumber(+)
and c.fcsg_creator = cu1.cusr_user_id(+)
and c.fcsg_canvasser = cu2.cusr_user_id(+)
and e.fexp_org_id = ?
这个语句是不是没有办法避免fexpense表的全表扫描,因为我已经把where条件中用到fexpense的字段都分别做了索引,而且还对fexpense表做了analyse。。。。
哪位大侠能帮忙解决下。。。
------解决方案----------------------主表的SQL
SELECT e.fexp_org_id
FROM fexpense e
WHERE e.fexp_org_id = :1
AND (e.fexp_creator = :2 OR
e.fexp_consign_id IN
(SELECT fcsg_consign_id FROM fconsign WHERE fcsg_creator = :2))
------解决方案--------------------不要用 OR
换成 UNION