SQL执行计划问题:where条件是主键(NUMBER类型字段)LIKE :VAR,为什么执行计划不走索引?
中文社区 (MOSC)
数据库 (MOSC)
6 Replies
Last updated on February 26, 2013
This question is Not Answered.
环境:
ORACLE 10.2.0.4
表C_MP,数据量1100多万,主键MP_ID(是唯一索引),MP_NO是唯一索引
用PL/SQL及toad工具分析下面语句的执行计划,结果一样:
SELECT * FROM C_MP A WHERE A.MP_ID LIKE :VAR1;------执行计划全表扫描
SELECT * FROM C_MP A WHERE A.MP_NO LIKE :VAR2;-----执行计划INDEX RANGE SCAN
两个语句条件都是唯一索引,只是一个是主键条件,一个不是,为什么执行计划完全不同?
这个和数据库版本有关系吗?还是其他原因?
谢谢!
To view full details, sign in with your My Oracle Support Community account.
Don't have a My Oracle Support
Community account? Click to get started!
My Oracle Support provides customers with access to over a million knowledge articles and a vibrant support community of peers and Oracle experts.
Oracle offers a comprehensive and fully integrated stack of cloud applications and platform services. For more information about Oracle (NYSE:ORCL), visit oracle.com. © Oracle | Contact and Chat | Support | Communities | Connect with us | Legal Notices | Terms of Use