ITPub博客

首页 > Linux操作系统 > Linux操作系统 > SQL优化

SQL优化

原创 Linux操作系统 作者:zhangweicai74 时间:2008-05-23 08:08:59 0 删除 编辑
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,
在不动索引的情况下,怎样优化?
请高手支招

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

请登录后发表评论 登录
全部评论

注册时间:2007-12-27

  • 博文量
    35
  • 访问量
    78476