select * from (
select ip.part_no,ith1.dated indate,row_number() over(partition by ith1.part_no order by ith1.dated desc) rn
from ifsapp.inventory_transaction_hist_tab ith1,
ifsapp.inventory_part_tab ip
where ith1.part_no=ip.part_no
and ith1.contract=ip.contract
and ith1.transaction_code='OOREC'
and ith1.date_applied>=to_date('2006-1-1','yyyy-mm-dd')
and ip.contract='SKY'
and ip.sk_part_category_db='1')
where rn=1
Explain plan:
SELECT STATEMENT, GOAL = CHOOSE Cost=2198 Cardinality=35506 Bytes=1349228
VIEW Object wner=IFSAPP Cost=2198 Cardinality=35506 Bytes=1349228
WINDOW SORT PUSHED RANK Cost=2198 Cardinality=35506 Bytes=1881818
HASH JOIN Cost=1883 Cardinality=35506 Bytes=1881818
TABLE ACCESS FULL Object wner=IFSAPP Object name=INVENTORY_PART_TAB Cost=136 Cardinality=10277 Bytes=164432
TABLE ACCESS BY INDEX ROWID Object wner=IFSAPP Object name=INVENTORY_TRANSACTION_HIST_TAB Cost=1724 Cardinality=93121 Bytes=3445477
INDEX RANGE SCAN Object wner=IFSAPP Object name=INVENTORY_TRANSACTION_HIST7_IX Cost=589 Cardinality=3
inventory_transaction_hist_tab 有16000000记录.我的这个SQL运行了1262 S,
在不动索引的情况下,怎样优化?
请高手支招
select ip.part_no,ith1.dated indate,row_number() over(partition by ith1.part_no order by ith1.dated desc) rn
from ifsapp.inventory_transaction_hist_tab ith1,
ifsapp.inventory_part_tab ip
where ith1.part_no=ip.part_no
and ith1.contract=ip.contract
and ith1.transaction_code='OOREC'
and ith1.date_applied>=to_date('2006-1-1','yyyy-mm-dd')
and ip.contract='SKY'
and ip.sk_part_category_db='1')
where rn=1
Explain plan:
SELECT STATEMENT, GOAL = CHOOSE Cost=2198 Cardinality=35506 Bytes=1349228
VIEW Object wner=IFSAPP Cost=2198 Cardinality=35506 Bytes=1349228
WINDOW SORT PUSHED RANK Cost=2198 Cardinality=35506 Bytes=1881818
HASH JOIN Cost=1883 Cardinality=35506 Bytes=1881818
TABLE ACCESS FULL Object wner=IFSAPP Object name=INVENTORY_PART_TAB Cost=136 Cardinality=10277 Bytes=164432
TABLE ACCESS BY INDEX ROWID Object wner=IFSAPP Object name=INVENTORY_TRANSACTION_HIST_TAB Cost=1724 Cardinality=93121 Bytes=3445477
INDEX RANGE SCAN Object wner=IFSAPP Object name=INVENTORY_TRANSACTION_HIST7_IX Cost=589 Cardinality=3
inventory_transaction_hist_tab 有16000000记录.我的这个SQL运行了1262 S,
在不动索引的情况下,怎样优化?
请高手支招

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/12391917/viewspace-293564/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/12391917/viewspace-293564/