数据仓库中有个表 mid_base_outpatient_info,表 有个索引列DIM_DATE,
因为业务需要,现在的业务处理是通过一个管道函数进行关联得出这个表某个时间段的数据,
每次只是选择5天,占2年的数据时很少的,但是它不走索引,主要就是因为关联了这个管道函数,
我现在只能通过修改函数的一些东西,关联的这个结构形式不能变,
所以求教怎么让管道函数 走索引查询啊
----函数功能是返回输入时间返回的日期,pa_rerun 是实体表
create or replace function run_date(p_start_date date, p_end_date date)
return sysdate_run
pipelined
is
v_date date;
v_dim_date date_col;
v_countnumber;
begin
select count(*) into v_count from pa_rerun;
if v_count = 0 then
v_date := p_start_date;
while v_dateset autotrace traceonly;
SQL> select t.dim_date,t.dim_org from mid_base_outpatient_info t
2where exists(select dim_date from table(run_date(date'2012-7-1',date'2012-7-6'))m
3
where m.dim_date=t.dim_date);
已选择173447行。
0db block gets
193626consistent gets
180329physical reads
116redo size
3986078bytes sent via SQL*Net to client
127577bytes received via SQL*Net from client
11565SQL*Net roundtrips to/from client