视图上含有row_number分析函数没法走索引

王朝other·作者佚名  2008-06-01
窄屏简体版  字體: |||超大  

问题:有如下的sql性能差:

select rowid,PKG_LIFE_QUERY_FUNC.F_GET_DEPOSIT_ACCOUNT_VALUE(DEPOSIT_ID,ACCOUNT_CODE) as ACCOUNT_VALUE,PKG_LIFE_QUERY_FUNC.F_GET_DEPOSIT_ACCOUNT_VALUE(DEPOSIT_ID,ACCOUNT_CODE) as ACCOUNT_VALUE,a.* from V_CUST_DEPOSIT_LIST a where ( account_code='27902')

V_CUST_DEPOSIT_LIST 是一个视图如下:

create or replace view v_cust_deposit_list as

select row_number() over(order by tcdl.account_code,

trunc(tcdl.deposit_date), to_number(decode(tcd.distri_type,

'1', 1, '2', 5, '3', decode(tpf.fee_type, 169, 2, 69, 6),

'10', 3, '71', 4, '8', 9, 8))) rn,tcdl.*

from t_cust_deposit_list tcdl,

t_capital_distribute tcd,

t_product_fee tpf

where tcdl.capital_id = tcd.capital_id(+)

and tcd.prem_id = tpf.list_id(+)

order by tcdl.account_code,

trunc(tcdl.deposit_date),

to_number(decode(tcd.distri_type,'1',1,'2',5,'3',

decode(tpf.fee_type, 169, 2, 69, 6),'10',3,'71',4,'8',9,8));

在t_cust_deposit_list有account_code;

原因:由于在视图上含有row_number分析函数,所以没法走索引:把语句改为:

select rowid,

PKG_LIFE_QUERY_FUNC.F_GET_DEPOSIT_ACCOUNT_VALUE(DEPOSIT_ID,ACCOUNT_CODE) as ACCOUNT_VALUE,

PKG_LIFE_QUERY_FUNC.F_GET_DEPOSIT_ACCOUNT_VALUE(DEPOSIT_ID,ACCOUNT_CODE) as ACCOUNT_VALUE,

a.*

from (

select row_number() over (order by tcdl.account_code,trunc(tcdl.deposit_date),to_number(decode(tcd.distri_type,'1',1,'3',decode(tpf.fee_type,169,2,69,5),'10',3,'71',4,'2',9,8))) rn,tcdl.*

from

(select tcd2.* from t_cust_deposit_list tcd2

where tcd2.account_code='27902') tcdl,t_capital_distribute tcd,t_product_fee tpf

where tcdl.capital_id = tcd.capital_id(+) and tcd.prem_id = tpf.list_id(+)

order by tcdl.account_code,trunc(tcdl.deposit_date),to_number(decode(tcd.distri_type,'1',1,'3',decode(tpf.fee_type,169,2,69,5),'10',3,'71',4,'2',9,8))

) a

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航