降序索引浅析

本文通过示例分析了Oracle数据库中降序索引的使用,包括如何创建和使用降序索引,以及它们在部分升序、部分降序排序查询中的效果。通过对比不同查询计划,展示了降序索引如何影响执行效率,以及如何通过创建反向索引来优化查询性能。
摘要由CSDN通过智能技术生成
--降序索引

EODA@PROD1> drop table t purge;

Table dropped.

EODA@PROD1> set echo on
EODA@PROD1> create table t as select * from all_objects;

Table created.

EODA@PROD1> create index t_idx on t(owner,object_type,object_name);

Index created.

EODA@PROD1> begin
  2           dbms_stats.gather_table_stats(user, 'T', method_opt=> 'for all indexed columns');
  3         end;
  4         /

PL/SQL procedure successfully completed.

EODA@PROD1> set autotrace traceonly explain
EODA@PROD1> start /tmp/opt.sql
EODA@PROD1> select owner, object_type
  2  from t
  3  where owner between 'T' and 'Z'
  4  and object_type is not null
  5  order by owner DESC, object_type DESC;

Execution Plan
----------------------------------------------------------
Plan hash value: 2685572958

-------------------------------------------------------------------------------------
| Id  | Operatio
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值