稍微调下表的次序,你试试是否有所改进。
select h.clr_code,sum(g.pound_bal) as rest_mtl_qty
from raw_mat_stock_info g,
tbmms_bal_analysis_salodr d,
raw_mat_lot_info h
where g.whouse_code='ABC' and g.comp_code=d.division_code
and g.po_id=d.salodr_code
and d.mtl_code=h.fab_code
and g.lot_no=h.lot_no
and g.comp_code=h.comp_code
group by h.clr_code;
select h.clr_code,sum(g.pound_bal) as rest_mtl_qty
from raw_mat_stock_info g,
tbmms_bal_analysis_salodr d,
raw_mat_lot_info h
where g.whouse_code='ABC' and g.comp_code=d.division_code
and g.po_id=d.salodr_code
and d.mtl_code=h.fab_code
and g.lot_no=h.lot_no
and g.comp_code=h.comp_code
group by h.clr_code;
select h.clr_code,sum(g.pound_bal) as rest_mtl_qty
from raw_mat_lot_info h,
raw_mat_stock_info g,
tbmms_bal_analysis_salodr d
where
g.lot_no=h.lot_no
and g.comp_code=h.comp_code
and d.mtl_code=h.fab_code
and d.division_code=g.comp_code
and d.salodr_code=g.po_id
and g.whouse_code='ABC'
group by h.clr_code;
2.因为在执行你的sql时,
oracle会把你的g,h,d三张表均放入回滚段中,
如果其它字段特别多,记录量特别大,
可能出现回滚段和内存页面的调进调出问题。
建议在此三张表中针对相关字段建立视图,再在视图内查询[start test.sql(create view...;select...;)]。
晚上的电灯突然变暗,原来是电耗子进来了。
你的sql运行时,估计资源被你独占(67秒,很那个)。
当然建视图时,一开始可能远不止67秒,
但建立后,在正式运行前,仅需追加增量的部分(where条件相信能用..._code或date字段来判别)。
再在视图中建立查询,运行时也许只要几秒种。诚惶诚恐。不知是否能达到同胞的认同呢?