|
leonarding 发表于 2013-3-27 17:02 ![]()
oracle R2 版本
SQL> select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
PL/SQL Release 11.2.0.3.0 - Production
CORE 11.2.0.3.0 Production
TNS for Linux: Version 11.2.0.3.0 - Production
NLSRTL Version 11.2.0.3.0 - Production
SQL> select table_name,index_name,partitioned,status from user_indexes where table_name in ('PARTITION_LEO9','PARTITION_LEO10');
TABLE_NAME INDEX_NAME PAR STATUS
------------------------------ ------------------------------ --- --------
PARTITION_LEO9 IDX_PARTITION_LEO9 NO VALID
PARTITION_LEO10 IDX_PARTITION_LEO10 YES N/A
SQL> set autot on
SQL> select /*+ index(partition_leo9 idx_partition_leo9) */ count(*) from partition_leo9 where object_id>1000 and object_id<8000;
COUNT(*)
----------
6883
Execution Plan
----------------------------------------------------------
Plan hash value: 549732231
----------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |
----------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 151 (0)| 00:00:02 |
| 1 | SORT AGGREGATE | | 1 | 13 | | |
|* 2 | INDEX RANGE SCAN| IDX_PARTITION_LEO9 | 6539 | 85007 | 151 (0)| 00:00:02 |
----------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("OBJECT_ID">1000 AND "OBJECT_ID"<8000)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
34 recursive calls
0 db block gets
121 consistent gets
0 physical reads
0 redo size
527 bytes sent via SQL*Net to client
520 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
4 sorts (memory)
0 sorts (disk)
1 rows processed
SQL> select /*+ index(partition_leo10 idx_partition_leo10) */ count(*) from partition_leo10 where object_id>1000 and object_id<8000;
COUNT(*)
----------
6883
Execution Plan
----------------------------------------------------------
Plan hash value: 785094176
---------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
---------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | 1 | 13 | 138 (0)| 00:00:02 | | |
| 1 | SORT AGGREGATE | | 1 | 13 | | | | |
| 2 | PARTITION RANGE SINGLE| | 5129 | 66677 | 138 (0)| 00:00:02 | 1 | 1 |
|* 3 | INDEX RANGE SCAN | IDX_PARTITION_LEO10 | 5129 | 66677 | 138 (0)| 00:00:02 | 1 | 1 |
---------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
3 - access("OBJECT_ID">1000 AND "OBJECT_ID"<8000)
Note
-----
- dynamic sampling used for this statement (level=2)
Statistics
----------------------------------------------------------
240 recursive calls
0 db block gets
294 consistent gets
0 physical reads
0 redo size
527 bytes sent via SQL*Net to client
520 bytes received via SQL*Net from client
2 SQL*Net roundtrips to/from client
28 sorts (memory)
0 sorts (disk)
1 rows processed
针对这个版本本地分区范围内的,仍然是全局索引效率高。我同时测试另一个版本11g R1好象结果也是相反的 |
|