exists 关联管道函数,不走索引,怎么解决??

[复制链接]
查看11 | 回复2 | 2013-11-11 22:44:03 | 显示全部楼层 |阅读模式
数据仓库中有个表 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行。

执行计划
----------------------------------------------------------
Plan hash value: 3143510547
--------------------------------------------------------------------------------
-------------------------------
| Id| Operation
| Name
| Rows|
Bytes | Cost (%CPU)| Time |
--------------------------------------------------------------------------------
-------------------------------
| 0 | SELECT STATEMENT
|
| 38787 |
795K| 40525 (2)| 00:08:07 |
|*1 |HASH JOIN RIGHT SEMI
|
| 38787 |
795K| 40525 (2)| 00:08:07 |
| 2 | COLLECTION ITERATOR PICKLER FETCH| RUN_DATE
| |
|
|
|
| 3 | TABLE ACCESS FULL
| MID_BASE_OUTPATIENT_INFO |5003K|
90M| 40414 (1)| 00:08:05 |
--------------------------------------------------------------------------------
-------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
1 - access("T"."DIM_DATE"=VALUE(KOKBF$))

统计信息
----------------------------------------------------------
185recursive calls

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

0sorts (memory)

0sorts (disk)
173447rows processed

回复

使用道具 举报

千问 | 2013-11-11 22:44:03 | 显示全部楼层
有没有人帮分析下?谢谢了
现在每个存储过程都关联这个,不走索引,每天都要多浪费一些没必要的性能消耗
回复

使用道具 举报

千问 | 2013-11-11 22:44:03 | 显示全部楼层
想想是否能用一条语句实现
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行