|
第三阶段New Feature/OCM Exam Preparation(31-36)
- explain plan for
- SELECT c.cust_city, t.calendar_quarter_desc, SUM(s.amount_sold) sales_amount
- FROM sh.sales s, sh.times t, sh.customers c, sh.channels ch
- WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id AND s.channel_id = ch.channel_id
- AND c.cust_state_province = 'FL'
- AND ch.channel_desc = 'Direct Sales'
- AND t.calendar_quarter_desc IN ('2000-01', '2000-02','1999-12') GROUP BY c.cust_city,
- t.calendar_quarter_desc;
复制代码- [oracle@station17 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Fri Jul 28 20:48:34 2017
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter parallel_
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- fast_start_parallel_rollback string LOW
- parallel_adaptive_multi_user boolean TRUE
- parallel_automatic_tuning boolean FALSE
- parallel_degree_limit string CPU
- parallel_degree_policy string MANUAL
- parallel_execution_message_size integer 16384
- parallel_force_local boolean FALSE
- parallel_instance_group string
- parallel_io_cap_enabled boolean FALSE
- parallel_max_servers integer 80
- parallel_min_percent integer 0
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- parallel_min_servers integer 0
- parallel_min_time_threshold string AUTO
- parallel_server boolean FALSE
- parallel_server_instances integer 1
- parallel_servers_target integer 32
- parallel_threads_per_cpu integer 2
- recovery_parallelism integer 0
- SQL> conn sh/oracle_4U
- Connected.
- explain plan for
- SELECT c.cust_city, t.calendar_quarter_desc, SUM(s.amount_sold) sales_amount
- FROM sh.sales s, sh.times t, sh.customers c, sh.channels ch
- WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id AND s.channel_id = ch.channel_id
- AND c.cust_state_province = 'FL'
- AND ch.channel_desc = 'Direct Sales'
- AND t.calendar_quarter_desc IN ('2000-01', '2000-02','1999-12') GROUP BY c.cust_city,
- 8 t.calendar_quarter_desc;
- Explained.
- SQL> set linesize 2000
- SQL> @?/rdbms/admin/utlxplp
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Plan hash value: 1865285285
- ------------------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
- ------------------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 607 | 46132 | 920 (2)| 00:00:12 | | |
- | 1 | HASH GROUP BY | | 607 | 46132 | 920 (2)| 00:00:12 | | |
- |* 2 | HASH JOIN | | 2337 | 173K| 919 (2)| 00:00:12 | | |
- | 3 | PART JOIN FILTER CREATE | :BF0000 | 274 | 4384 | 18 (0)| 00:00:01 | | |
- |* 4 | TABLE ACCESS FULL | TIMES | 274 | 4384 | 18 (0)| 00:00:01 | | |
- |* 5 | HASH JOIN | | 12456 | 729K| 900 (2)| 00:00:11 | | |
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- | 6 | MERGE JOIN CARTESIAN | | 383 | 14937 | 408 (1)| 00:00:05 | | |
- |* 7 | TABLE ACCESS FULL | CHANNELS | 1 | 13 | 3 (0)| 00:00:01 | | |
- | 8 | BUFFER SORT | | 383 | 9958 | 405 (1)| 00:00:05 | | |
- |* 9 | TABLE ACCESS FULL | CUSTOMERS | 383 | 9958 | 405 (1)| 00:00:05 | | |
- | 10 | PARTITION RANGE JOIN-FILTER| | 918K| 18M| 489 (2)| 00:00:06 |:BF0000|:BF0000|
- | 11 | TABLE ACCESS FULL | SALES | 918K| 18M| 489 (2)| 00:00:06 |:BF0000|:BF0000|
- ------------------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 2 - access("S"."TIME_ID"="T"."TIME_ID")
- 4 - filter("T"."CALENDAR_QUARTER_DESC"='1999-12' OR "T"."CALENDAR_QUARTER_DESC"='2000-01' OR
- "T"."CALENDAR_QUARTER_DESC"='2000-02')
- 5 - access("S"."CUST_ID"="C"."CUST_ID" AND "S"."CHANNEL_ID"="CH"."CHANNEL_ID")
- 7 - filter("CH"."CHANNEL_DESC"='Direct Sales')
- 9 - filter("C"."CUST_STATE_PROVINCE"='FL')
- 28 rows selected.
- SQL>
复制代码- SQL> conn / as sysdba
- Connected.
- SQL> show parameter parallel_degree
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- parallel_degree_limit string CPU
- parallel_degree_policy string MANUAL
- SQL> alter system set parallel_degree_policy=limited;
- System altered.
- SQL> conn sh/oracle_4U
- Connected.
- explain plan for
- SELECT c.cust_city, t.calendar_quarter_desc, SUM(s.amount_sold) sales_amount
- FROM sh.sales s, sh.times t, sh.customers c, sh.channels ch
- WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id AND s.channel_id = ch.channel_id
- AND c.cust_state_province = 'FL'
- AND ch.channel_desc = 'Direct Sales'
- AND t.calendar_quarter_desc IN ('2000-01', '2000-02','1999-12') GROUP BY c.cust_city,
- 8 t.calendar_quarter_desc;
- Explained.
- SQL> @?/rdbms/admin/utlxplp
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Plan hash value: 1865285285
- ------------------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop |
- ------------------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 607 | 46132 | 920 (2)| 00:00:12 | | |
- | 1 | HASH GROUP BY | | 607 | 46132 | 920 (2)| 00:00:12 | | |
- |* 2 | HASH JOIN | | 2337 | 173K| 919 (2)| 00:00:12 | | |
- | 3 | PART JOIN FILTER CREATE | :BF0000 | 274 | 4384 | 18 (0)| 00:00:01 | | |
- |* 4 | TABLE ACCESS FULL | TIMES | 274 | 4384 | 18 (0)| 00:00:01 | | |
- |* 5 | HASH JOIN | | 12456 | 729K| 900 (2)| 00:00:11 | | |
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- | 6 | MERGE JOIN CARTESIAN | | 383 | 14937 | 408 (1)| 00:00:05 | | |
- |* 7 | TABLE ACCESS FULL | CHANNELS | 1 | 13 | 3 (0)| 00:00:01 | | |
- | 8 | BUFFER SORT | | 383 | 9958 | 405 (1)| 00:00:05 | | |
- |* 9 | TABLE ACCESS FULL | CUSTOMERS | 383 | 9958 | 405 (1)| 00:00:05 | | |
- | 10 | PARTITION RANGE JOIN-FILTER| | 918K| 18M| 489 (2)| 00:00:06 |:BF0000|:BF0000|
- | 11 | TABLE ACCESS FULL | SALES | 918K| 18M| 489 (2)| 00:00:06 |:BF0000|:BF0000|
- ------------------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 2 - access("S"."TIME_ID"="T"."TIME_ID")
- 4 - filter("T"."CALENDAR_QUARTER_DESC"='1999-12' OR "T"."CALENDAR_QUARTER_DESC"='2000-01' OR
- "T"."CALENDAR_QUARTER_DESC"='2000-02')
- 5 - access("S"."CUST_ID"="C"."CUST_ID" AND "S"."CHANNEL_ID"="CH"."CHANNEL_ID")
- 7 - filter("CH"."CHANNEL_DESC"='Direct Sales')
- 9 - filter("C"."CUST_STATE_PROVINCE"='FL')
- 28 rows selected.
- SQL>
复制代码- SQL> conn / as sysdba
- Connected.
- SQL> show parameter parallel_degree
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- parallel_degree_limit string CPU
- parallel_degree_policy string LIMITED
- SQL> alter system set parallel_degree_policy=auto;
- System altered.
- SQL> conn sh/oracle_4U
- Connected.
- explain plan for
- SELECT c.cust_city, t.calendar_quarter_desc, SUM(s.amount_sold) sales_amount
- FROM sh.sales s, sh.times t, sh.customers c, sh.channels ch
- WHERE s.time_id = t.time_id AND s.cust_id = c.cust_id AND s.channel_id = ch.channel_id
- AND c.cust_state_province = 'FL'
- AND ch.channel_desc = 'Direct Sales'
- AND t.calendar_quarter_desc IN ('2000-01', '2000-02','1999-12') GROUP BY c.cust_city,
- 8 t.calendar_quarter_desc;
- Explained.
- SQL> @?/rdbms/admin/utlxplp
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- Plan hash value: 3013537432
- -----------------------------------------------------------------------------------------------------------------------------------------
- | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time | Pstart| Pstop | TQ |IN-OUT| PQ Distrib |
- -----------------------------------------------------------------------------------------------------------------------------------------
- | 0 | SELECT STATEMENT | | 607 | 46132 | 512 (2)| 00:00:07 | | | | | |
- | 1 | PX COORDINATOR | | | | | | | | | | |
- | 2 | PX SEND QC (RANDOM) | :TQ10004 | 607 | 46132 | 512 (2)| 00:00:07 | | | Q1,04 | P->S | QC (RAND)|
- | 3 | HASH GROUP BY | | 607 | 46132 | 512 (2)| 00:00:07 | | | Q1,04 | PCWP | |
- | 4 | PX RECEIVE | | 2337 | 173K| 511 (2)| 00:00:07 | | | Q1,04 | PCWP | |
- | 5 | PX SEND HASH | :TQ10003 | 2337 | 173K| 511 (2)| 00:00:07 | | | Q1,03 | P->P | HASH |
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- |* 6 | HASH JOIN | | 2337 | 173K| 511 (2)| 00:00:07 | | | Q1,03 | PCWP | |
- | 7 | PX RECEIVE | | 1 | 13 | 2 (0)| 00:00:01 | | | Q1,03 | PCWP | |
- | 8 | PX SEND BROADCAST | :TQ10000 | 1 | 13 | 2 (0)| 00:00:01 | | | Q1,00 | P->P | BROADCAST|
- | 9 | PX BLOCK ITERATOR | | 1 | 13 | 2 (0)| 00:00:01 | | | Q1,00 | PCWC | |
- |* 10 | TABLE ACCESS FULL | CHANNELS | 1 | 13 | 2 (0)| 00:00:01 | | | Q1,00 | PCWP | |
- |* 11 | HASH JOIN | | 9347 | 575K| 509 (2)| 00:00:07 | | | Q1,03 | PCWP | |
- | 12 | PART JOIN FILTER CREATE| :BF0001 | 274 | 4384 | 10 (0)| 00:00:01 | | | Q1,03 | PCWP | |
- | 13 | PX RECEIVE | | 274 | 4384 | 10 (0)| 00:00:01 | | | Q1,03 | PCWP | |
- | 14 | PX SEND BROADCAST | :TQ10001 | 274 | 4384 | 10 (0)| 00:00:01 | | | Q1,01 | P->P | BROADCAST|
- | 15 | PX BLOCK ITERATOR | | 274 | 4384 | 10 (0)| 00:00:01 | | | Q1,01 | PCWC | |
- |* 16 | TABLE ACCESS FULL | TIMES | 274 | 4384 | 10 (0)| 00:00:01 | | | Q1,01 | PCWP | |
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- |* 17 | HASH JOIN | | 49822 | 2286K| 498 (2)| 00:00:06 | | | Q1,03 | PCWP | |
- | 18 | PX RECEIVE | | 383 | 9958 | 225 (1)| 00:00:03 | | | Q1,03 | PCWP | |
- | 19 | PX SEND BROADCAST | :TQ10002 | 383 | 9958 | 225 (1)| 00:00:03 | | | Q1,02 | P->P | BROADCAST|
- | 20 | PX BLOCK ITERATOR | | 383 | 9958 | 225 (1)| 00:00:03 | | | Q1,02 | PCWC | |
- |* 21 | TABLE ACCESS FULL | CUSTOMERS | 383 | 9958 | 225 (1)| 00:00:03 | | | Q1,02 | PCWP | |
- | 22 | PX BLOCK ITERATOR | | 918K| 18M| 271 (2)| 00:00:04 |:BF0001|:BF0001| Q1,03 | PCWC | |
- |* 23 | TABLE ACCESS FULL | SALES | 918K| 18M| 271 (2)| 00:00:04 |:BF0001|:BF0001| Q1,03 | PCWP | |
- -----------------------------------------------------------------------------------------------------------------------------------------
- Predicate Information (identified by operation id):
- ---------------------------------------------------
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- 6 - access("S"."CHANNEL_ID"="CH"."CHANNEL_ID")
- 10 - filter("CH"."CHANNEL_DESC"='Direct Sales')
- 11 - access("S"."TIME_ID"="T"."TIME_ID")
- 16 - filter("T"."CALENDAR_QUARTER_DESC"='1999-12' OR "T"."CALENDAR_QUARTER_DESC"='2000-01' OR
- "T"."CALENDAR_QUARTER_DESC"='2000-02')
- 17 - access("S"."CUST_ID"="C"."CUST_ID")
- 21 - filter("C"."CUST_STATE_PROVINCE"='FL')
- 23 - filter(SYS_OP_BLOOM_FILTER_LIST(SYS_OP_BLOOM_FILTER(:BF0002,"S"."CUST_ID"),SYS_OP_BLOOM_FILTER(:BF0000,"S"."CHANNEL_ID")))
- Note
- PLAN_TABLE_OUTPUT
- ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
- -----
- <font color="Red">- automatic DOP: Computed Degree of Parallelism is 2</font>
- 46 rows selected.
- SQL>
复制代码
|
|