oracle - 尽管有提示,Oracle 不使用不可见索引
问题描述
我似乎弄乱了索引提示语法,但我已经尝试了我能想到的每一个模式/表/索引组合。
表和索引与 SYS 用户(我正在测试索引提示的用户)处于不同的架构中
这是没有提示的语句
select id from car.event where dat < sysdate and type != 0
这些是我尝试为架构dat_type
中的索引实现索引提示的方法car
select /*+ index(car.event car.dat_type) */ id from car.event where dat < sysdate and type != 0
select /*+ index(event car.dat_type) */ id from car.event where dat < sysdate and type != 0
select /*+ index(car.event dat_type) */ id from car.event where dat < sysdate and type != 0
select /*+ index(event dat_type) */ id from car.event where dat < sysdate and type != 0
select /*+ index(event (dat, type)) */ id from car.event where dat < sysdate and type != 0
所以对于这五个语句,我查找了我的五个不同的 sql_id 并查看了执行计划,如下所示
select * from table(dbms_xplan.display_awr([sql_id]));
但是它们都没有显示索引的使用情况。它们都使用 20 的 DoP。我是否必须明确禁用并行性才能使用索引?或者有人可以更正我的索引提示的语法吗?
这是dat_type
索引的定义
create index car.dat_type on car.event(dat, type) online;
编辑:索引设置为不可见,因此其他语句无法使用索引,但我想通过索引提示显式使用它。据我了解,索引提示的不可见性应该不是问题。如果我错了,请纠正我。
解决方案
我偶然发现了这篇文章,它表明实际上不应该只使用索引提示就可以使用不可见索引。但是,不可见索引可以与附加提示一起使用USE_INVISIBLE_INDEXES
。
所以这就是我让它工作的方式:
select /*+ use_invisible_indexes index(car dat_type) */ id from car.event where dat < sysdate and type != 0
推荐阅读
- perl - 如何使用foreach perl读取目录中的每个文件
- python - 我正在尝试制作一个输出您的信用评分的应用程序
- python - Python 中的 `board[x, y]` 和 `board[x][y]` 有区别吗?
- ios - 为什么在 UIView 上绘制的 Rectangle 是模糊的,但是在放大 UIView 时不会向 UIView 添加图层?
- java - FTP 服务器连接在大约 5 分钟后关闭
- javascript - JQuery:可拖动 div 的 z-index 排序
- php - 编辑保存在 codeigniter 中的日期
- mysql - VS 2017 MYsql 错误你已经有连接
- google-app-engine - 如何为我的 GAE 项目映射自定义域?
- java - 如何在 Maven 中运行具有不同配置的 UI 测试