并行与hint同时存在

Posted dayu-liu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了并行与hint同时存在相关的知识,希望对你有一定的参考价值。

 

 

1.指定并行度为3

select /*+ parallel(t1,3) */ object_type,count(*) from PARALLEL_TEST1 t1 group by object_type order by count(*);

select /*+ parallel(t1,3) */ object_type,count(*) from PARALLEL_TEST1 t1 group by object_type order by count(*);SQL> 

OBJECT_TYPE                                COUNT(*)
--------------------------------------------------------------------- ----------
EDITION                                        1
RULE                                           2
DESTINATION                                       2
JAVA SOURCE                                       2
SCHEDULE                                       4
SCHEDULER GROUP                                    4
LOB PARTITION                                       7
DIRECTORY                                       7
INDEXTYPE                                       7
UNIFIED AUDIT POLICY                                   8
WINDOW                                           9
CLUSTER                                       10
CONTEXT                                       10
PROGRAM                                       10
RESOURCE PLAN                                      11
EVALUATION CONTEXT                                  12
JOB CLASS                                      14
UNDEFINED                                      15
CONSUMER GROUP                                      18
RULE SET                                      18
JOB                                          23
QUEUE                                          25
TABLE SUBPARTITION                                  32
XML SCHEMA                                      44
OPERATOR                                      54
INDEX PARTITION                                  187
PROCEDURE                                     201
LIBRARY                                      228
TYPE BODY                                     229
SEQUENCE                                     254
TABLE PARTITION                                  258
JAVA DATA                                     309
FUNCTION                                     346
TRIGGER                                      593
LOB                                         857
JAVA RESOURCE                                    1015
PACKAGE BODY                                    1245
PACKAGE                                     1306
TABLE                                        2388
TYPE                                        2536
INDEX                                        4268
VIEW                                        6487
JAVA CLASS                                   30816
SYNONYM                                    37081

44 rows selected.


Execution Plan
----------------------------------------------------------
Plan hash value: 4204599738

---------------------------------------------------------------------------------------------------------------------------
| Id  | Operation            | Name         | Rows  | Bytes | Cost (%CPU)| Time     |      TQ  |IN-OUT| PQ Distrib |
---------------------------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT        |             | 82500 |    1047K|     159   (4)| 00:00:01 |          |      |          |
|   1 |  PX COORDINATOR         |             |         |         |          |         |          |      |          |
|   2 |   PX SEND QC (ORDER)        | :TQ10002         | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,02 | P->S | QC (ORDER) |
|   3 |    SORT ORDER BY        |             | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,02 | PCWP |          |
|   4 |     PX RECEIVE            |             | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,02 | PCWP |          |
|   5 |      PX SEND RANGE        | :TQ10001         | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,01 | P->P | RANGE      |
|   6 |       HASH GROUP BY        |             | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,01 | PCWP |          |
|   7 |        PX RECEIVE        |             | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,01 | PCWP |          |
|   8 |     PX SEND HASH        | :TQ10000         | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,00 | P->P | HASH      |
|   9 |      HASH GROUP BY        |             | 82500 |    1047K|     159   (4)| 00:00:01 |    Q1,00 | PCWP |          |
|  10 |       PX BLOCK ITERATOR |             | 82500 |    1047K|     155   (1)| 00:00:01 |    Q1,00 | PCWC |          |
|  11 |        TABLE ACCESS FULL| PARALLEL_TEST1 | 82500 |    1047K|     155   (1)| 00:00:01 |    Q1,00 | PCWP |          |
---------------------------------------------------------------------------------------------------------------------------

Note
-----
   - dynamic statistics used: dynamic sampling (level=2)
   - Degree of Parallelism is 3 because of table property


Statistics
----------------------------------------------------------
     26  recursive calls
      0  db block gets
       1941  consistent gets
    107  physical reads
      0  redo size
       1834  bytes sent via SQL*Net to client
    573  bytes received via SQL*Net from client
      4  SQL*Net roundtrips to/from client
      4  sorts (memory)
      0  sorts (disk)
     44  rows processed




DBMS_SQLTUNE.REPORT_SQL_MONITOR(SESSION_ID=>40)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
SQL Monitoring Report

SQL Text
------------------------------
select /*+ parallel(t1,3) */ object_type,count(*) from PARALLEL_TEST1 t1 group by object_type order by count(*)

Global Information
------------------------------
 Status          :    DONE (ALL ROWS)
 Instance ID         :    1
 Session         :    SYS (40:34283)
 SQL ID          :    84vj8sv8vuxja
 SQL Execution ID    :    16777216
 Execution Started   :    08/24/2018 11:09:37
 First Refresh Time  :    08/24/2018 11:09:37
 Last Refresh Time   :    08/24/2018 11:09:37
 Duration         :    .024032s
 Module/Action         :    [email protected] (TNS V1-V3)/-
 Service         :    dayupdb1
 Program         :    [email protected] (TNS V1-V3)
 Fetch Calls         :    4

Global Stats
======================================================================================
| Elapsed |   Cpu   |     IO    | Cluster  |  Other   | Fetch | Buffer | Read | Read  |
| Time(s) | Time(s) | Waits(s) | Waits(s) | Waits(s) | Calls |    Gets  | Reqs | Bytes |
======================================================================================
|    0.09 |    0.06 |      0.01 |     0.01 |    0.02 |       4 |     1813 |   13 | 856KB |
======================================================================================

Parallel Execution Details (DOP=3 , Servers Allocated=6)
 Instances  : 2

==========================================================================================================================================
| Instance |      Name        | Type  | Server# | Elapsed |   Cpu   |    IO    | Cluster    |  Other   | Buffer | Read | Read  | Wait Events |
|       |            |        |          | Time(s) | Time(s) | Waits(s) | Waits(s) | Waits(s) |  Gets  | Reqs | Bytes | (sample #)  |
==========================================================================================================================================
| 1       | PX Coordinator | QC    |          |    0.02 |    0.01 |         |        |     0.01 |      5 |       |     . |         |
| 1       | p000        | Set 1 |        1 |    0.02 |    0.01 |    0.00 |       0.00 |     0.00 |    752 |     3 | 128KB |         |
| 1       | p001        | Set 1 |        2 |    0.02 |    0.01 |    0.00 |       0.00 |     0.01 |    658 |     3 | 112KB |         |
| 2       | p000        | Set 1 |        3 |    0.02 |    0.01 |    0.01 |       0.00 |       |    398 |     7 | 616KB |         |
| 1       | p002        | Set 2 |        1 |    0.00 |    0.00 |         |        |       |        |       |     . |         |
| 1       | p003        | Set 2 |        2 |    0.00 |    0.00 |         |        |     0.00 |        |       |     . |         |
| 2       | p001        | Set 2 |        3 |    0.00 |    0.00 |         |        |       |        |       |     . |         |
==========================================================================================================================================

Instance Drill-Down
================================================================================================================================
| Instance | Process Names        | Elapsed |   Cpu    |    IO    | Cluster  |  Other     | Buffer | Read | Read  | Wait Events |
|       |                | Time(s) | Time(s) | Waits(s) | Waits(s) | Waits(s) |  Gets  | Reqs | Bytes |           |
================================================================================================================================
|    1       | QC p000 p001 p002 p003 |     0.07 |    0.04 |     0.01 |     0.00 |     0.02 |   1415 |    6 | 240KB |           |
|    2       | p000 p001            |     0.02 |    0.02 |     0.01 |     0.00 |      |    398 |    7 | 616KB |           |
================================================================================================================================

SQL Plan Monitoring Details (Plan Hash Value=4204599738)
====================================================================================================================================================================
| Id |         Operation         |        Name      |  Rows    | Cost |   Time    | Start  | Execs |    Rows   | Read | Read  |  Mem  | Activity | Activity Detail |
|    |                     |              | (Estim) |      | Active(s) | Active |        | (Actual) | Reqs | Bytes | (Max) |   (%)     |   (# samples)   |
====================================================================================================================================================================
|  0 | SELECT STATEMENT          |              |     |      |     1 |     +0 |      7 |        44 |      |       |       |      |           |
|  1 |     PX COORDINATOR          |              |     |      |     1 |     +0 |      7 |        44 |      |       |       |      |           |
|  2 |      PX SEND QC (ORDER)         | :TQ10002       |   82500 |  159 |     1 |     +0 |      3 |        44 |      |       |       |      |           |
|  3 |       SORT ORDER BY         |              |   82500 |  159 |     1 |     +0 |      3 |        44 |      |       |  6144 |      |           |
|  4 |        PX RECEIVE             |              |   82500 |  159 |     1 |     +0 |      3 |        44 |      |       |       |      |           |
|  5 |         PX SEND RANGE         | :TQ10001       |   82500 |  159 |     1 |     +0 |      3 |        44 |      |       |       |      |           |
|  6 |          HASH GROUP BY         |              |   82500 |  159 |     1 |     +0 |      3 |        44 |      |       |    5M |      |           |
|  7 |           PX RECEIVE         |              |   82500 |  159 |     1 |     +0 |      3 |       105 |      |       |       |      |           |
|  8 |        PX SEND HASH         | :TQ10000       |   82500 |  159 |     1 |     +0 |      3 |       105 |      |       |       |      |           |
|  9 |         HASH GROUP BY         |              |   82500 |  159 |     1 |     +0 |      3 |       105 |      |       |    6M |      |           |
| 10 |          PX BLOCK ITERATOR  |              |   82500 |  155 |     1 |     +0 |      3 |     90953 |      |       |       |      |           |
| 11 |           TABLE ACCESS FULL | PARALLEL_TEST1 |   82500 |  155 |     1 |     +0 |     39 |     90953 |   13 | 856KB |       |      |           |
====================================================================================================================================================================

 

以上是关于并行与hint同时存在的主要内容,如果未能解决你的问题,请参考以下文章

并发与并行

[Go] 并发和并行的区别

Oracle Parallel Hint 中的并行度

如何在 python 中并行化以下代码片段?

oracle 怎样使用并行查询

线程池与并行度