1.一张大表300万记录,表名my_objects;
其中object_id 是primary key,
2.建立索引my_obj2(object_id,object_name)
3. analyze table my_objects estimate statisticssample 5 percent
for all indexes
for all indexed columns;
4.select object_id, object_name from my_object where object_id=99999 and object_name='myname';
我发现系统执行计划用了主键索引,而没有用my_obj2.
5.删除my_obj2,重新建立 my_obj2(object_id,object_name)
,但是不做第三步.
再执行:select object_id, object_name from my_object where object_id=99999 and object_name='myname';
这次用了my_obj2索引.
我想知道,系统应该一直用my_obj2索引才对,为什么执行第3步,执行计划就使用不同的计划?
请指导.谢谢!!
|