Oracle数据库数据恢复、性能优化

找回密码
注册
搜索
热搜: 活动 交友 discuz
发新帖

0

积分

1

好友

5

主题
1#
发表于 2013-3-15 09:27:49 | 查看: 5883| 回复: 10
本环境是VMware Workstation虚拟机环境,每个节点是一个一核的CPU。


SQL> select * from v$version;

BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
PL/SQL Release 11.2.0.1.0 - Production
CORE    11.2.0.1.0      Production
TNS for Linux: Version 11.2.0.1.0 - Production
NLSRTL Version 11.2.0.1.0 - Production



instance #2:
SQL> show parameter instance_g

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_groups                      string      prod,prod2
parallel_instance_group              string


instance #1:
SQL> show parameter instance_g

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_groups                      string      prod,prod1
parallel_instance_group              string



SQL> alter session set parallel_instance_group='prod';
Session altered.


SQL> set autotrace trace exp

SQL> select /*+ parallel(3) */ count(*) from t;

Execution Plan
----------------------------------------------------------
Plan hash value: 3126468333

--------------------------------------------------------------------------------------------------------
| Id  | Operation              | Name     | Rows  | Cost (%CPU)| Time     |    TQ  |IN-OUT| PQ Distrib |
--------------------------------------------------------------------------------------------------------
|   0 | SELECT STATEMENT       |          |     1 |   108   (0)| 00:00:02 |        |      |            |
|   1 |  SORT AGGREGATE        |          |     1 |            |          |        |      |            |
|   2 |   PX COORDINATOR       |          |       |            |          |        |      |            |
|   3 |    PX SEND QC (RANDOM) | :TQ10000 |     1 |            |          |  Q1,00 | P->S | QC (RAND)  |
|   4 |     SORT AGGREGATE     |          |     1 |            |          |  Q1,00 | PCWP |            |
|   5 |      PX BLOCK ITERATOR |          | 73489 |   108   (0)| 00:00:02 |  Q1,00 | PCWC |            |
|   6 |       TABLE ACCESS FULL| T        | 73489 |   108   (0)| 00:00:02 |  Q1,00 | PCWP |            |
--------------------------------------------------------------------------------------------------------

Note
-----
   - Degree of Parallelism is 3 because of hint



SQL> alter session set parallel_instance_group='prod1';

Session altered.

SQL> select /*+ parallel(3) */ count(*) from t;

Execution Plan
----------------------------------------------------------
Plan hash value: 2966233522

-------------------------------------------------------------------
| Id  | Operation          | Name | Rows  | Cost (%CPU)| Time     |
-------------------------------------------------------------------
|   0 | SELECT STATEMENT   |      |     1 |   293   (1)| 00:00:04 |
|   1 |  SORT AGGREGATE    |      |     1 |            |          |
|   2 |   TABLE ACCESS FULL| T    | 73489 |   293   (1)| 00:00:04 |
-------------------------------------------------------------------

Note
-----
   - Degree of Parallelism is 1 because of hint



可以看到,当在一个实例执行并行查询的时候并行度就变成 1 了(在2个实例执行的时候并行度可以开到65535),为什么?求指点,谢谢!



2#
发表于 2013-3-15 09:32:43

alter sytsem flush shared_pool;

alter session set events '10053 trace name context forever,level 1';
alter session set "_px_trace"="compilation","execution","messaging";

运行你的语句


把生成的TRACE上传

回复 只看该作者 道具 举报

3#
发表于 2013-3-15 09:46:30
已上传。。。

prod1_ora_26534_PARALLEL.rar

11.26 KB, 下载次数: 1039

回复 只看该作者 道具 举报

4#
发表于 2013-3-15 10:22:05
在trace文件中发现:
parallel_instance_group has no instance members so                de
            fault DOP = 1Default DOP = 1

我已经用alter session set parallel_instance_group='prod1';
为什么会没有成员?

回复 只看该作者 道具 举报

5#
发表于 2013-3-15 10:49:03

**************************
Automatic degree of parallelism (ADOP)
**************************
Automatic degree of parallelism is enabled for this statement in hint mode.
kkopqSetDopReason: Reason why we chose this DOP is: hint.
Hint forces parallelism with dop=3


kxfplist
        Getting instance info for default group
kxfpGetTotalCpuCount
        kxfplist returned status: 2
kxfrDefaultDOP
        DOP Trace -- compute default DOP
            # CPU       = 1
            Threads/CPU = 2 ("parallel_threads_per_cpu")
            default DOP = 2 (# CPU * Threads/CPU)
            # instance alive = 0 (kxfpFindAvailableInstCnt)
            parallel_instance_group has no instance members so                de
            fault DOP = 1Default DOP = 1


AUTO DOP PLANS EVALUATION
***************************************
Compilation completed with Dop: 3.
  Cost_io:  292.00  Cost_cpu: 18671705.12
  Card:     1.00  Bytes:    0.00
  Cost:     292.58  Est_time:  3516ms
AutoDop: kkopqSetMaxDopInCursorEnv:In the Cursor Session Env, max DOP is set to 65535
*****************************
Number of Compilations tried: 1
*****************************
                       

回复 只看该作者 道具 举报

6#
发表于 2013-3-15 10:52:57
kxfpFindAvailableInstCnt ==>  instance alive = 0

session退出再 登陆试试

回复 只看该作者 道具 举报

7#
发表于 2013-3-15 11:14:53
本帖最后由 nan_dream 于 2013-3-15 11:16 编辑

退出重新登录还是不行,而且还发现一个很奇怪的现象:


SQL> show parameter instance_gr

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_groups                      string      prod,prod1
parallel_instance_group              string

SQL> select name,value,isdefault from v$ses_optimizer_env where sid=65 order by 3,1;

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
_smm_max_size                            50790 KB                  NO
_smm_min_size                            253 KB                    NO
_smm_px_max_size                         126976 KB                 NO
parallel_max_degree                      4                         NO
active_instance_count                    2                         YES
bitmap_merge_area_size                   1048576                   YES
cell_offload_compaction                  ADAPTIVE                  YES
cell_offload_plan_display                AUTO                      YES
cell_offload_processing                  true                      YES
cpu_count                                1                         YES
cursor_sharing                           exact                     YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
db_file_multiblock_read_count            54                        YES
dst_upgrade_insert_conv                  true                      YES
hash_area_size                           131072                    YES
is_recur_flags                           0                         YES
optimizer_capture_sql_plan_baselines     false                     YES
optimizer_dynamic_sampling               2                         YES
optimizer_features_enable                11.2.0.1                  YES
optimizer_index_caching                  0                         YES
optimizer_index_cost_adj                 100                       YES
optimizer_mode                           all_rows                  YES
optimizer_secure_view_merging            true                      YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
optimizer_use_invisible_indexes          false                     YES
optimizer_use_pending_statistics         false                     YES
optimizer_use_sql_plan_baselines         true                      YES
parallel_autodop                         0                         YES
parallel_ddl_mode                        enabled                   YES
parallel_ddldml                          0                         YES
parallel_degree                          0                         YES
parallel_degree_limit                    65535                     YES
parallel_degree_policy                   manual                    YES
parallel_dml_mode                        disabled                  YES
parallel_execution_enabled               true                      YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
parallel_force_local                     false                     YES
parallel_min_time_threshold              10                        YES
parallel_query_default_dop               0                         YES
parallel_query_mode                      enabled                   YES
parallel_threads_per_cpu                 2                         YES
pga_aggregate_target                     245760 KB                 YES
query_rewrite_enabled                    true                      YES
query_rewrite_integrity                  enforced                  YES
result_cache_mode                        MANUAL                    YES
skip_unusable_indexes                    true                      YES
sort_area_retained_size                  0                         YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
sort_area_size                           65536                     YES
star_transformation_enabled              false                     YES
statistics_level                         typical                   YES
total_cpu_count                          2                         YES
transaction_isolation_level              read_commited             YES
workarea_size_policy                     auto                      YES

50 rows selected.



SQL> alter session set parallel_instance_group='prod1';

Session altered.

SQL> select name,value,isdefault from v$ses_optimizer_env where sid=65 order by 3,1;

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
_smm_max_size                            50790 KB                  NO
_smm_min_size                            253 KB                    NO
_smm_px_max_size                         126976 KB                 NO
parallel_execution_enabled               false                     NO
parallel_max_degree                      4                         NO
active_instance_count                    0                         YES
bitmap_merge_area_size                   1048576                   YES
cell_offload_compaction                  ADAPTIVE                  YES
cell_offload_plan_display                AUTO                      YES
cell_offload_processing                  true                      YES
cpu_count                                1                         YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
cursor_sharing                           exact                     YES
db_file_multiblock_read_count            54                        YES
dst_upgrade_insert_conv                  true                      YES
hash_area_size                           131072                    YES
is_recur_flags                           0                         YES
optimizer_capture_sql_plan_baselines     false                     YES
optimizer_dynamic_sampling               2                         YES
optimizer_features_enable                11.2.0.1                  YES
optimizer_index_caching                  0                         YES
optimizer_index_cost_adj                 100                       YES
optimizer_mode                           all_rows                  YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
optimizer_secure_view_merging            true                      YES
optimizer_use_invisible_indexes          false                     YES
optimizer_use_pending_statistics         false                     YES
optimizer_use_sql_plan_baselines         true                      YES
parallel_autodop                         0                         YES
parallel_ddl_mode                        enabled                   YES
parallel_ddldml                          0                         YES
parallel_degree                          0                         YES
parallel_degree_limit                    65535                     YES
parallel_degree_policy                   manual                    YES
parallel_dml_mode                        disabled                  YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
parallel_force_local                     false                     YES
parallel_min_time_threshold              10                        YES
parallel_query_default_dop               0                         YES
parallel_query_mode                      enabled                   YES
parallel_threads_per_cpu                 2                         YES
pga_aggregate_target                     245760 KB                 YES
query_rewrite_enabled                    true                      YES
query_rewrite_integrity                  enforced                  YES
result_cache_mode                        MANUAL                    YES
skip_unusable_indexes                    true                      YES
sort_area_retained_size                  0                         YES

NAME                                     VALUE                     ISD
---------------------------------------- ------------------------- ---
sort_area_size                           65536                     YES
star_transformation_enabled              false                     YES
statistics_level                         typical                   YES
total_cpu_count                          2                         YES
transaction_isolation_level              read_commited             YES
workarea_size_policy                     auto                      YES

50 rows selected.


当设置了alter session set parallel_instance_group='prod1';之后,parallel_execution_enabled和 active_instance_count这两个参数改变了。

回复 只看该作者 道具 举报

8#
发表于 2013-3-15 11:57:37
有空我在11.2.0.3 上测一下, 可能是 配置问题 ,也可能是bug

回复 只看该作者 道具 举报

9#
发表于 2013-3-15 14:25:36
本帖最后由 anbob 于 2013-3-15 14:26 编辑

Notices:
sys@ANBOB>alter system set instance_groups='prod,prod1' scope=spfile sid='inst1';

sys@ANBOB>show parameter instance_g

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_groups                      string      prod,prod1

sys@ANBOB>alter system set instance_groups='prod','prod1' scope=spfile  sid='inst1';
sys@ANBOB>show parameter instance_g

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_groups                      string      prod, prod1


I thought you might be using the above, is it?

回复 只看该作者 道具 举报

10#
发表于 2013-3-15 14:48:40
原因已找到,由于粗心,在设置instance_groups参数的时候,写成了
alter system set instance_groups='prod,prod1';

正确写法应该是:
alter system set instance_groups='prod','prod1';

在设置parallel_instance_group为prod1的时候,找不到prod1这个实例组,当然就不存在成员了。

parallel_execution_enabled和 active_instance_count两个参数的修改问题也就迎刃而解了。


又是粗心惹的祸!!看来得好好面壁一下了

回复 只看该作者 道具 举报

11#
发表于 2013-3-15 14:50:56
anbob 发表于 2013-3-15 14:25
Notices:
sys@ANBOB>alter system set instance_groups='prod,prod1' scope=spfile sid='inst1';

yes,u r right.

回复 只看该作者 道具 举报

您需要登录后才可以回帖 登录 | 注册

QQ|手机版|Archiver|Oracle数据库数据恢复、性能优化

GMT+8, 2024-5-17 16:36 , Processed in 0.055030 second(s), 23 queries .

Powered by Discuz! X2.5

© 2001-2012 Comsenz Inc.

回顶部
TEL/電話+86 13764045638
Email service@parnassusdata.com
QQ 47079569