文档的解释: Top-level slave decides not to share cursor
意思是说: 并行执行计划中,slave进程不能共享Query Coordinator生成的cursor, slave进程自己hard parse后生成新的cursor
看一个由“TEMP TABLE TRANSFORMATION”导致PQ_SLAVE_MISMATCH的例子:
SQL> select * from v$version;
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 t1 as select * from dba_objects;
exec dbms_stats.gather_table_stats(user,'T1');
with tbwd as (select /*+ materialize */ * from t1)
select /*+ parallel(3) */ count(*) from tbwd;
select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 7su5qsgxcc2mg, child number 0
-------------------------------------
with tbwd as (select /*+ materialize */ * from t1) select /*+
parallel(3) */ count(*) from tbwd
Plan hash value: 1001073145
-------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 42 (100)| | | | |
| 1 | TEMP TABLE TRANSFORMATION | | | | | | | | |
| 2 | PX COORDINATOR | | | | | | | | |
| 3 | PX SEND QC (RANDOM) | :TQ10000 | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | P->S | QC (RAND) |
| 4 | LOAD AS SELECT | | | | | | Q1,00 | PCWP | |
| 5 | PX BLOCK ITERATOR | | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | PCWC | |
|* 6 | TABLE ACCESS FULL | T1 | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | PCWP | |
| 7 | SORT AGGREGATE | | 1 | | | | | | |
| 8 | PX COORDINATOR | | | | | | | | |
| 9 | PX SEND QC (RANDOM) | :TQ20000 | 1 | | | | Q2,00 | P->S | QC (RAND) |
| 10 | SORT AGGREGATE | | 1 | | | | Q2,00 | PCWP | |
| 11 | VIEW | | 16047 | | 20 (0)| 00:00:01 | Q2,00 | PCWP | |
| 12 | PX BLOCK ITERATOR | | 16047 | 1394K| 20 (0)| 00:00:01 | Q2,00 | PCWC | |
|* 13 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6617_249112 | 16047 | 1394K| 20 (0)| 00:00:01 | Q2,00 | PCWP | |
-------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
6 - access(:Z>=:Z AND :Z<=:Z)
13 - access(:Z>=:Z AND :Z<=:Z)
Note
-----
- Degree of Parallelism is 3 because of hint
select PLAN_HASH_VALUE,CHILD_NUMBER,executions from v$sql where sql_id='7su5qsgxcc2mg'
PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS
--------------- ------------ ----------
1001073145 0 1
1001073145 1 0
select sql_id,child_number,pq_slave_mismatch
from v$sql_shared_cursor where sql_id='7su5qsgxcc2mg';
SQL_ID CHILD_NUMBER P
------------- ------------ -
7su5qsgxcc2mg 0 N
7su5qsgxcc2mg 1 Y
如果设置10053(alter system set events '10053 trace name context forever, level 1';),
将会看到Query Coordinator进程和p000进程都生成了trace文件,由此也可以证明slave进程自己hard parse后生成新的cursor。
意思是说: 并行执行计划中,slave进程不能共享Query Coordinator生成的cursor, slave进程自己hard parse后生成新的cursor
看一个由“TEMP TABLE TRANSFORMATION”导致PQ_SLAVE_MISMATCH的例子:
SQL> select * from v$version;
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 t1 as select * from dba_objects;
exec dbms_stats.gather_table_stats(user,'T1');
with tbwd as (select /*+ materialize */ * from t1)
select /*+ parallel(3) */ count(*) from tbwd;
select * from table(dbms_xplan.display_cursor);
PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL_ID 7su5qsgxcc2mg, child number 0
-------------------------------------
with tbwd as (select /*+ materialize */ * from t1) select /*+
parallel(3) */ count(*) from tbwd
Plan hash value: 1001073145
-------------------------------------------------------------------------------------------------------------------------------------
| Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | TQ |IN-OUT| PQ Distrib |
-------------------------------------------------------------------------------------------------------------------------------------
| 0 | SELECT STATEMENT | | | | 42 (100)| | | | |
| 1 | TEMP TABLE TRANSFORMATION | | | | | | | | |
| 2 | PX COORDINATOR | | | | | | | | |
| 3 | PX SEND QC (RANDOM) | :TQ10000 | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | P->S | QC (RAND) |
| 4 | LOAD AS SELECT | | | | | | Q1,00 | PCWP | |
| 5 | PX BLOCK ITERATOR | | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | PCWC | |
|* 6 | TABLE ACCESS FULL | T1 | 16047 | 1394K| 22 (0)| 00:00:01 | Q1,00 | PCWP | |
| 7 | SORT AGGREGATE | | 1 | | | | | | |
| 8 | PX COORDINATOR | | | | | | | | |
| 9 | PX SEND QC (RANDOM) | :TQ20000 | 1 | | | | Q2,00 | P->S | QC (RAND) |
| 10 | SORT AGGREGATE | | 1 | | | | Q2,00 | PCWP | |
| 11 | VIEW | | 16047 | | 20 (0)| 00:00:01 | Q2,00 | PCWP | |
| 12 | PX BLOCK ITERATOR | | 16047 | 1394K| 20 (0)| 00:00:01 | Q2,00 | PCWC | |
|* 13 | TABLE ACCESS FULL | SYS_TEMP_0FD9D6617_249112 | 16047 | 1394K| 20 (0)| 00:00:01 | Q2,00 | PCWP | |
-------------------------------------------------------------------------------------------------------------------------------------
Predicate Information (identified by operation id):
---------------------------------------------------
6 - access(:Z>=:Z AND :Z<=:Z)
13 - access(:Z>=:Z AND :Z<=:Z)
Note
-----
- Degree of Parallelism is 3 because of hint
select PLAN_HASH_VALUE,CHILD_NUMBER,executions from v$sql where sql_id='7su5qsgxcc2mg'
PLAN_HASH_VALUE CHILD_NUMBER EXECUTIONS
--------------- ------------ ----------
1001073145 0 1
1001073145 1 0
select sql_id,child_number,pq_slave_mismatch
from v$sql_shared_cursor where sql_id='7su5qsgxcc2mg';
SQL_ID CHILD_NUMBER P
------------- ------------ -
7su5qsgxcc2mg 0 N
7su5qsgxcc2mg 1 Y
如果设置10053(alter system set events '10053 trace name context forever, level 1';),
将会看到Query Coordinator进程和p000进程都生成了trace文件,由此也可以证明slave进程自己hard parse后生成新的cursor。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/37279/viewspace-2125697/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/37279/viewspace-2125697/