Pstart and Pstop in sql plan with interval partition

select * from v$version;
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
PL/SQL Release 11.2.0.4.0 - Production
CORE    11.2.0.4.0      Production
TNS for Linux: Version 11.2.0.4.0 - Production
NLSRTL Version 11.2.0.4.0 - Production


create table tab1(id number, name varchar2(10))
    partition by range(id) interval(1)
    ( partition p0 values less than (1) );


Table created.


insert into tab1 values(1,'111');
insert into tab1 values(2,'111');
insert into tab1 values(3,'111');
insert into tab1 values(4,'111');
commit;

col partition_name for a30
col high_value for a10
    select partition_position, partition_name, high_value,interval
    from user_tab_partitions
   where table_name = 'TAB1';
PARTITION_POSITION PARTITION_NAME                 HIGH_VALUE INT
------------------ ------------------------------ ---------- ---
                 1 P0                             1          NO
                 2 SYS_P91                        2          YES
                 3 SYS_P92                        3          YES
                 4 SYS_P93                        4          YES
                 5 SYS_P94                        5          YES


set lines 200 pages 999
select * from tab1 where id=10;

select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID  0v29ruajpskdb, child number 0
-------------------------------------
select * from tab1 where id=10


Plan hash value: 8842412


-----------------------------------------------------------------------------------------------
| Id  | Operation              | Name | Rows  | Bytes | Cost (%CPU)| Time     | Pstart| Pstop |
-----------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |      |       |       |     3 (100)|          |       |       |
|   1 |  PARTITION RANGE SINGLE|      |     1 |    20 |     3   (0)| 00:00:01 |    11 |    11 |
|*  2 |   TABLE ACCESS FULL    | TAB1 |     1 |    20 |     3   (0)| 00:00:01 |    11 |    11 |
-----------------------------------------------------------------------------------------------


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


   2 - filter("ID"=10)


Note
-----
   - dynamic sampling used for this statement (level=2)

23 rows selected.


tab1表只有5个分区, 但是执行计划里的"Pstart"和"Pstop"却是11,
这是因为如果所有的分区都创建了,id=11所在的分区的PARTITION_POSITION就是11,
user_tab_partitions.partition_position并不是实际的字段,
通过select view_text from dba_views where view_name=upper('user_tab_partitions')可以看到
它的值是row_number() over (partition by o.name order by tp.part#)。




请使用浏览器的分享功能分享到微信等