代码改变世界

oracle 索引,组合索引

2017-04-24 13:39  安松  阅读(477)  评论(0编辑  收藏  举报

1. 组合索引   

   id,code      组合

   id,number  组合

 

2. 排序cost

    使用 id ,cost=0

    使用 id+code  cost=0

    使用 id+number  cost=6

    使用 code   cost=125

    使用 number cost=125

    使用 id          cost=0

 

--select b.*,rownum rn from t_order b order by b.id desc;--0,0,0
--select b.*,rownum rn from t_order b order by b.id desc,b.number desc;  --6 6 1
--select b.*,rownum rn from t_order b order by b.id desc,b.code desc; --0,0,0
select b.*,rownum rn from t_order b order by b.number desc; --125,125,3

  

3.关于执行计划 http://www.cnblogs.com/liuyongcn/p/3553337.html