表如下:
create table PMO_WBS
(
id VARCHAR2(40) not null,
plan_id VARCHAR2(40) not null,
user_id VARCHAR2(40),
obs_id VARCHAR2(40),
calendar_id VARCHAR2(40),
classify_id VARCHAR2(40),
parent_id VARCHAR2(40),
proj_id VARCHAR2(40),
wbs_code VARCHAR2(100) not null,
wbs_code_prefix VARCHAR2(2000),
wbs_name VARCHAR2(200) not null
)id是主键,对 id, plan_id,obs_id 四个个字段建立联合索引。
我查询select id, plan_id,obs_id from pmo_wbs where plan_id='a' ,走索引;
但是我如果查询字段中增加一个或者两个不在联合索引里的字段时(例如:select id, plan_id,obs_id,user_id,wbs_code from pmo_wbs where plan_id='a'),就不走索引。
跪求高手帮忙。
create table PMO_WBS
(
id VARCHAR2(40) not null,
plan_id VARCHAR2(40) not null,
user_id VARCHAR2(40),
obs_id VARCHAR2(40),
calendar_id VARCHAR2(40),
classify_id VARCHAR2(40),
parent_id VARCHAR2(40),
proj_id VARCHAR2(40),
wbs_code VARCHAR2(100) not null,
wbs_code_prefix VARCHAR2(2000),
wbs_name VARCHAR2(200) not null
)id是主键,对 id, plan_id,obs_id 四个个字段建立联合索引。
我查询select id, plan_id,obs_id from pmo_wbs where plan_id='a' ,走索引;
但是我如果查询字段中增加一个或者两个不在联合索引里的字段时(例如:select id, plan_id,obs_id,user_id,wbs_code from pmo_wbs where plan_id='a'),就不走索引。
跪求高手帮忙。
1. PMO_WBS数据量太少,全表扫描比走索引更高效。
2. PMO_WBS数据量太大,查询的结果集数据量也大,也是全表扫描比走索引更高效。至于select id, plan_id,obs_id from pmo_wbs where plan_id='a' 为什么走索引,原因是:因为查询的3个字段全部为索引字段,
这样你查询的结果直接从索引段中取数,而无须从PMO_WBS读取数据。
不确定的情况下,最好不要建组合索引