创建本地索引和全局索引

LOCALITY:表明分区索引是LOCAL的还是GLOBAL的。

--创建分区索引:
create index IDX_MGR_BASE_MGR on T_PM_MGR_BASE (MGR_CODE) LOCAL parallel 16 nologging ;
SQL> select * from T_PM_MGR_BASE  where data_date=20131012 and mgr_code='03319';

184 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 949292481

-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation			   | Name	      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT		   |		      |   195 | 29250 |   196	(0)| 00:00:03 |       |       |
|   1 |  PARTITION LIST SINGLE		   |		      |   195 | 29250 |   196	(0)| 00:00:03 |   KEY |   KEY |
|   2 |   TABLE ACCESS BY LOCAL INDEX ROWID| T_PM_MGR_BASE    |   195 | 29250 |   196	(0)| 00:00:03 |   654 |   654 |
|*  3 |    INDEX RANGE SCAN		   | IDX_MGR_BASE_MGR |   195 |       |     3	(0)| 00:00:01 |   654 |   654 |
-----------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   3 - access("MGR_CODE"='03319')

走了本地索引:
create index IDX_MGR_BASE_MGR on T_PM_MGR_BASE (MGR_CODE)  parallel 16 nologging ;
---创建全局索引

SQL> select index_name from dba_indexes  where index_name='IDX_MGR_BASE_MGR';

INDEX_NAME
------------------------------
IDX_MGR_BASE_MGR

SQL>  explain plan for select * from T_PM_MGR_BASE where mgr_code='03319';

Explained.

SQL> select * from table(dbms_xplan.display());

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Plan hash value: 158496794

-----------------------------------------------------------------------------------------------------------------------
| Id  | Operation			   | Name	      | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-----------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT		   |		      | 91239 |    13M| 90120	(1)| 00:18:02 |       |       |
|   1 |  TABLE ACCESS BY GLOBAL INDEX ROWID| T_PM_MGR_BASE    | 91239 |    13M| 90120	(1)| 00:18:02 | ROWID | ROWID |
|*  2 |   INDEX RANGE SCAN		   | IDX_MGR_BASE_MGR | 91239 |       |   272	(1)| 00:00:04 |       |       |
-----------------------------------------------------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("MGR_CODE"='03319')

14 rows selected.



转载于:https://www.cnblogs.com/zhaoyangjian724/p/3798101.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值