In my previous posts, I have demonstrated how Oracle "auto"computes the DoP when using the PARALLEL Hint by itself, even when PARALLEL_DEGREE_POLICY is set to MANUAL. This "auto"computed value is CPU_COUNT x PARALLEL_THREADS_PER_CPU.
How do we limit the DoP ?
1. PARALLEL_MAX_SERVERS is an instance-wide limit, not usable at the session level.
2. Resource Manager configuration can be used to limit the number of PX Servers used
3. PARALLEL_DEGREE_LIMIT, unfortunately, is not usable when PARALLEL_DEGREE_POLICY is MANUAL
As expected, the query uses 16 PX Servers (and not the table-level definition of 4). Can we use PARALLEL_DEGREE_LIMIT ?
No, it actually still used 16 PX servers f or the second execution.
What about PARALLEL_MAX_SERVERS ?
Yes, PARALLEL_MAX_SERVERS restricted the next run of the query to 4 PX Servers. However, this parameter limits the total concurrent usage of PX Servers at the instance level. It cannot be applied or derived to the session level.
UPDATE : Another method pointed out to me by Mladen Gogala is to use the Resource Manager to limit the number of PX Servers a session can request.
.
.
.
How do we limit the DoP ?
1. PARALLEL_MAX_SERVERS is an instance-wide limit, not usable at the session level.
2. Resource Manager configuration can be used to limit the number of PX Servers used
3. PARALLEL_DEGREE_LIMIT, unfortunately, is not usable when PARALLEL_DEGREE_POLICY is MANUAL
[oracle@localhost ~]$ sqlplus '/ as sysdba' SQL*Plus: Release 11.2.0.2.0 Production on Tue Mar 24 22:57:18 2015 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SYS>show parameter cpu NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cpu_count integer 4 parallel_threads_per_cpu integer 4 resource_manager_cpu_allocation integer 4 SYS>show parameter parallel_degree_policy NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ parallel_degree_policy string MANUAL SYS>show parameter parallel_max NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ parallel_max_servers integer 64 SYS> SYS>select * from dba_rsrc_io_calibrate; no rows selected SYS> SYS>connect hemant/hemant Connected. HEMANT>select degree from user_tables where table_name = 'LARGE_TABLE'; DEGREE ---------------------------------------- 4 HEMANT>select /*+ PARALLEL */ count(*) from Large_Table; COUNT(*) ---------- 4802944 HEMANT>select executions, px_servers_executions, sql_fulltext 2 from v$sqlstats 3 where sql_id = '8b0ybuspqu0mm'; EXECUTIONS PX_SERVERS_EXECUTIONS SQL_FULLTEXT ---------- --------------------- -------------------------------------------------------------------------------- 1 16 select /*+ PARALLEL */ count(*) from Large_Table HEMANT>
As expected, the query uses 16 PX Servers (and not the table-level definition of 4). Can we use PARALLEL_DEGREE_LIMIT ?
HEMANT>alter session set parallel_degree_limit=4; Session altered. HEMANT>select /*+ PARALLEL */ count(*) from Large_Table; COUNT(*) ---------- 4802944 HEMANT>select executions, px_servers_executions, sql_fulltext 2 from v$sqlstats 3 where sql_id = '8b0ybuspqu0mm'; EXECUTIONS PX_SERVERS_EXECUTIONS SQL_FULLTEXT ---------- --------------------- -------------------------------------------------------------------------------- 2 32 select /*+ PARALLEL */ count(*) from Large_Table HEMANT>
No, it actually still used 16 PX servers f or the second execution.
What about PARALLEL_MAX_SERVERS ?
HEMANT>connect / as sysdba Connected. SYS>alter system set parallel_max_servers=4; System altered. SYS>connect hemant/hemant Connected. HEMANT>select /*+ PARALLEL */ count(*) from Large_Table; COUNT(*) ---------- 4802944 HEMANT>select executions, px_servers_executions, sql_fulltext 2 from v$sqlstats 3 where sql_id = '8b0ybuspqu0mm'; EXECUTIONS PX_SERVERS_EXECUTIONS SQL_FULLTEXT ---------- --------------------- -------------------------------------------------------------------------------- 3 36 select /*+ PARALLEL */ count(*) from Large_Table HEMANT>
Yes, PARALLEL_MAX_SERVERS restricted the next run of the query to 4 PX Servers. However, this parameter limits the total concurrent usage of PX Servers at the instance level. It cannot be applied or derived to the session level.
UPDATE : Another method pointed out to me by Mladen Gogala is to use the Resource Manager to limit the number of PX Servers a session can request.
.
.
.
1 comment:
Post a Comment