语句如下
SELECT substr(CED.Containerlocation,1,2) AreaNo, substr(CED.Containerlocation,3,3) BayNo,
substr(CED.Containerlocation,6,2) RowNo
FROM cy.T_CY_D_ContainerExistDepot CED
GROUP BY substr(CED.Containerlocation,3,3), substr(CED.Containerlocation,6,2), substr(CED.Containerlocation,1,2)其中Containerlocation列上有索引,语句如下
create index "IDX_EXISTDEPOT_LOCATION" on CY.T_CY_D_CONTAINEREXISTDEPOT (CONTAINERLOCATION)
tablespace CY
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
在执行时采用全表扫描加上索引线索,语句如下
SELECT /*+index(CY.T_CY_D_ContainerExistDepot "IDX_EXISTDEPOT_LOCATION" )*/ substr(CED.Containerlocation,1,2) AreaNo, substr(CED.Containerlocation,3,3) BayNo,
substr(CED.Containerlocation,6,2) RowNo
FROM cy.T_CY_D_ContainerExistDepot CED
GROUP BY substr(CED.Containerlocation,3,3), substr(CED.Containerlocation,6,2), substr(CED.Containerlocation,1,2)在执行时仍采用全表扫描我是在plsql中察看执行计划的请问是怎么回事
SELECT substr(CED.Containerlocation,1,2) AreaNo, substr(CED.Containerlocation,3,3) BayNo,
substr(CED.Containerlocation,6,2) RowNo
FROM cy.T_CY_D_ContainerExistDepot CED
GROUP BY substr(CED.Containerlocation,3,3), substr(CED.Containerlocation,6,2), substr(CED.Containerlocation,1,2)其中Containerlocation列上有索引,语句如下
create index "IDX_EXISTDEPOT_LOCATION" on CY.T_CY_D_CONTAINEREXISTDEPOT (CONTAINERLOCATION)
tablespace CY
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
在执行时采用全表扫描加上索引线索,语句如下
SELECT /*+index(CY.T_CY_D_ContainerExistDepot "IDX_EXISTDEPOT_LOCATION" )*/ substr(CED.Containerlocation,1,2) AreaNo, substr(CED.Containerlocation,3,3) BayNo,
substr(CED.Containerlocation,6,2) RowNo
FROM cy.T_CY_D_ContainerExistDepot CED
GROUP BY substr(CED.Containerlocation,3,3), substr(CED.Containerlocation,6,2), substr(CED.Containerlocation,1,2)在执行时仍采用全表扫描我是在plsql中察看执行计划的请问是怎么回事
如果真正使用函数时走索引,可以建基于函数的索引,function-based index(FBI,呵)FBI索引必须遵守下面的规则:
a) 必须使用基于成本的优化器,而且创建后必须对索引进行分析
b) 不能存储NULL值。因为任何函数在任何情况下都不能返回NULL值。
c)如果一个用户定义的PL/SQL例程失效了,而且这个例程被FBI索引用到了,那么相应的这个FBI索引会变成DISABLED
d)创建FBI索引得函数必须是确定性的。即,对于指定的输入,总是会返回确定的结果。
e) 索引的属主如果没有了在FBI索引里面使用的函数的执行权限,那么这个FBI索引会变成DISABLED.
f) 在创建索引得函数里面不能使用SUM等总计函数。
g)要把一个DISABLED了的索引重新变成ENABLED,这个函数必须首先是ENABLED的才可以。你的substr(),所截取的字符串如果是不能确定的话是不能建立函数索引的。除非固定返回字符串位置。如substr(filed,0,2)。但是如果条件中使用的是substr(filed,0,3),同样不会走该索引。那当然如果牺牲一些东西建多个substr() FBI索引是可以的。