我有一个oracle分区表,并且具有跟随sql的project_code
的索引。我们每天都会做两件事:
几天后,当我看到
的执行计划时,我发现查询速度较慢select * from MY_TABLE where project_code = '123'
索引仍然存在,但索引不适用于上面的sql
如果我删除并重新创建索引,索引将起作用并且查询更快
我不确定创建/删除分区是否会导致此问题,以及我如何解决此问题
-- Create table
create table MY_TABLE
(
country_code VARCHAR2(50),
project_code VARCHAR2(100),
item_code VARCHAR2(100),
BATCHES NUMBER
)
partition by list (BATCHES)
(
partition P1499736558 values (1499736558)
tablespace MY_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8M
next 1M
minextents 1
maxextents unlimited
),
partition P1499760276 values (1499760276)
tablespace MY_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8M
next 1M
minextents 1
maxextents unlimited
),
partition P1499846713 values (1499846713)
tablespace MY_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8M
next 1M
minextents 1
maxextents unlimited
),
partition P1499933071 values (1499933071)
tablespace MY_DATA
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 8M
next 1M
minextents 1
maxextents unlimited
)
);
-- Create/Recreate indexes
create index IDX_PROJECT_CODE on MY_TABLE (PROJECT_CODE)
tablespace MY_DATA
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 160K
next 1M
minextents 1
maxextents unlimited
);