为什么定义了索引,执行时却没有用到? 可能的几种情况:
1.统计信息错误或者不完全。尝试重建统计信息或者调整统计信息采样比率(默认为10%)后再试试。
2.10g以后的版本,optimizer_mode默认为ALL_ROWS,即采用CBO的方式。如果optimizer_mode不为ALL_ROWS,就要看看,你的SQL是不是通过RBO的方法执行的。
SQL> show parameter optimizer_mode
NAME                                        TYPE        VALUE
------------------------------------ ----------- ------------------------------
optimizer_mode                         string       ALL_ROWS
关于optimizer_mode参数的解释可以参考:The Oracle SQL Optimizers
3.复合索引(Concatenated Indexes)中的前导列没有作为查询条件
针对两个以上列建立的索引被称作复合索引。组合索引的顺序对索引的使用有决定性的影响,建立时需仔细考虑。
推荐阅读:Concatenated Indexes
4.条件列包含函数但没有创建函数索引(Function-Based Indexes)
一般来讲,Where子句中使用了函数,即使列上有索引,也不会使用到。8i后引入了Function-Based Indexes,可以解决函数列用不到索引的问题。
推荐阅读:
Oracle Function Based Indexes
Function-Based Indexes
5.小表没必要使用索引
表内的记录数很小,使用索引有可能还没有全表扫描快。即使你建了索引Optimizer也可能选择全表扫描。
推荐阅读:
Index the Correct Tables and Columns
When not to use indexes
Indexes On Small Tables Part I(需FQ)
6.选择性(Selectivity)
理想的选择性值当然是1,即列中所有的值都是不同的,这样的字段建立索引的效果最好。随着选择性的下降(即列中的重复值越来越多),索引使用的效果也在下降。当低到一定程度,使用索引的效果反倒不如全表扫描来的快速了。
B*TREE Indexes improve the performance of queries that select a small percentage of rows from a table. As a general guideline, we should create indexes on tables that are often queried for less than15% of the table's rows.This value may be higher in situations where all data can be retrieved from an index, or where the indexed columns can be used for joining to other tables.

The ratio of the number of distinct values in the indexed column / columns to the number of records in the table represents the selectivity of an index. The ideal selectivity is 1Such a selectivity can be reached only by unique indexes on NOT NULL columns.

Example with good Selectivity

A table having 100'000 records and one of its indexed column has 88000 distinct values, then the selectivity of this index is 88'000 / 10'0000 = 0.88.

Oracle implicitly creates indexes on the columns of all unique and primary keys that you define with integrity constraints. These indexes are the most selective and the most effective in optimizing performance. The selectivity of an index is the percentage of rows in a table having the same value for the indexed column. An index's selectivity is good if few rows have the same value.

Example with bad Selectivity

lf an index on a table of 100'000 records had only 500 distinct values, then the index's selectivity is 500 / 100'000 = 0.005 and in this case a query which uses the limitation of such an index will retum 100'000 / 500 = 200 records for each distinct value. It is evident that a full table scan is more efficient as using such an index where much more I/O is needed to scan repeatedly the index and the table.

推荐阅读:
How to measure Index Selectivity
Index the Correct Tables and Columns

转载请注明出粗:http://blog.csdn.net/pan_tian/article/details/17118339

Why NOT Use My Index相关推荐

  1. java.lang.IndexOutOfBoundsException: Index: 1, Size: 1

    哎 这类问题 本来都不打算记录的,但是自己写的时候还是犯了错误,一运行报错了 大致就是list 超出了 ,可能index size 值不一样( Index: 9, Size: 9, Index: 5, ...

  2. ThinkPHP3.2URL重写隐藏应用的入口文件index.php

    可以通过URL重写隐藏应用的入口文件index.PHP,下面是相关服务器的配置参考: [ Apache ] httpd.conf配置文件中加载了mod_rewrite.so模块 AllowOverri ...

  3. url中去掉index.php,方便redirect()

    01 配置文件 return Array( 'URL_MODEL' => '2', ); 02 index.php入口文件下面加入文件 .htaccess -->使用editplus--& ...

  4. e.V4p.C0/index.php,php-fpm进程在Kubernetes中接收SIGKILL信号

    我已经在其中配置了Nginx,PHP和php-fpm创建了ubuntu docker镜像 . 当我在Docker实例上运行它时工作正常 . 但是当我在kubernetes中运行相同的图像时,php-f ...

  5. 页面自动获取焦点影响页面切换效果_ReactIndex - 让文件夹index页面变得更有实用性 (替换传统Web服务器index页)...

    React的学习和家庭需求 工作上有需要接触React,而在正式接触相关产品之前为了了解一些基础.除了标准教程里面的例子意外,总觉得有点不够. 正好孩子他妈最近交给我一个任务: 儿子的学习资料需要整理 ...

  6. oracle查询不走索引全表扫描,使用索引快速全扫描(Index FFS)避免全表扫描的若干场景-Oracle...

    使用索引快速全扫描(Index FFS)避免全表扫描的若干场景 什么使用使用Index FFS比FTS好? Oracle 8的Concept手册中介绍: 1. 索引必须包含所有查询中参考到的列. 2. ...

  7. key mysql_mysql中key 、primary key 、unique key 与index区别

    mysql中索引是非常重要的知识点,相比其他的知识点,索引更难掌握,并且mysql中的索引种类也有很多,比如primary key .unique key 与index等等,本文章向大家介绍mysql ...

  8. 只需三分钟!只需创建一个vuex.js文件,让你马上学会使用Vuex,尽管Vuex是个鸡肋!(扔掉store文件夹和里面的index、getters、actions、mutations等js文件吧!)

    前情提示:有一天,我要实现一个效果→点击某个按钮改变一个全局变量,并且要让绑定了该变量的所有位置异步渲染.我试过用一个全局的js文件存放该变量,该变量值虽然改变了,但是没有做到异步渲染.接着我用win ...

  9. 存储引擎 K/V 分离下的index回写问题

    前言 近期在做on nvme hash引擎相关的事情,对于非全序的数据集的存储需求,相比于我们传统的LSM或者B-tree的数据结构来说 能够减少很多维护全序上的计算/存储资源.当然我们要保证hash ...

  10. IIS 7.5 去掉index.php 西数服务器

    //新建web.config 加上下面代码<?xml version="1.0"?> <configuration> <system.webServe ...

最新文章

  1. 机器学习时代,神经科学家如何阅读和解码人类的思想
  2. day 05 python基础
  3. 10款人气暴涨的PHP开源工具
  4. 苹果手机4g网速慢怎么办_2020 年双十一建议学生党买 4G 苹果手机吗?
  5. Windows常用快捷键汇总
  6. Python,Pandas,Bokeh Cheat Sheet-Data Science
  7. 区块链基础学习(一)
  8. Codeforces Round #350 (Div. 2) B. Game of Robots 水题
  9. 10道经典java面试题_实习生必问(java基础)
  10. 【修订总结】【五万字深度洞察】毒舌阿朱最看好的企业服务商
  11. 如何批量将图片转换为 PDF 文档
  12. 计算机怎么进入待机模式,电脑怎么进入待机模式
  13. Linux串口编程select方式
  14. ”好奇号“一切准备就绪即将开始探测火星之旅
  15. JAVA 短链码生成工具类
  16. python unicode转换
  17. 【小5聊】前端基础之上传图片等文件IE浏览器是会显示两个请求
  18. [文档] 软件测试说明书
  19. 大数据风控AI竞赛总结
  20. [Luogu 1516] 青蛙的约会

热门文章

  1. 用python计算化学题_(完整版)化学计算题解题方法(含答案)
  2. 经典对抗攻击Deepfool原理详解与代码解读
  3. 专辑名称:极品汽车发烧音乐精选-音乐宝典18CD(金碟收藏版)
  4. swift 判断当前设备网络是否可用
  5. You must address the points described in the following [1] lines before starting Elasticsearch.
  6. 台式计算机显卡驱动位置,台式电脑独立显卡怎么安装驱动的
  7. win7计算机自动关机设置在哪里设置方法,win7自动关机设置在哪?自动关机怎么设置具体方法...
  8. 网线/双绞线相关知识
  9. 计算机病毒是谁做的,第一个制造电脑病毒的人是谁?
  10. 2022 Google IO大会新技术