ITPub博客

首页 > 数据库 > Oracle > 11gOCM考试大纲

11gOCM考试大纲

Oracle 作者:dark_peng 时间:2015-09-01 11:18:56 0 删除 编辑

session 4 5 6 占的比例最大

11gServer Configuration
 

将数据文件创建到NFS上。
用opath打补丁

Direct NFS数据库拓扑结构


Oracle直接客户端扫描顺序


local:本地的网段
path:nfs服务器的ip
最多支持将数据文件放到四个nfs服务器中。

最后编译一下

Enterprise Manager Grid Control
 
Management Database Available

Data Management


并行

配置 和管理并行查询:

10g没有这个参数parallel_degree_policy

点击(此处)折叠或打开

  1. sys@TESTDB12>alter session set parallel_degree_policy=auto;

  2. Session altered.   --自动实现并行,那么就设置成auto的。

  3. sys@TESTDB12>alter session set parallel_min_time_threshold=20;

  4. Session altered.   --oracle估计,如果超过20s那么就开启并行。

启动并行DML

点击(此处)折叠或打开

  1. sh@TESTDB12>create table little_sales
  2.   2 partition by hash (time_id)
  3.   3 (partition ls1,partition ls2)
  4.   4 parallel
  5.   5 as
  6.   6 select * from sales where 1=2;

  7. Table created.

点击(此处)折叠或打开

  1. sh@TESTDB12>insert into little_sales
  2.   2 select *
  3.   3 from sales
  4.   4 where rownum < 5000;

  5. 4999 rows created.
v$pq_sesstat
这个视图可以看到上一个的操作是否用到并行。

点击(此处)折叠或打开

  1. sh@TESTDB12>select * from v$pq_sesstat;

  2. STATISTIC                 LAST_QUERY SESSION_TOTAL
  3. ------------------------------ ---------- -------------
  4. Queries Parallelized               0     1
  5. DML Parallelized                   0     0
  6. DDL Parallelized                   0     0
  7. DFO Trees                          0     1
  8. Server Threads                     0     0
  9. Allocation Height                  0     0
  10. Allocation Width                   0     0
  11. Local Msgs Sent                    0     66
  12. Distr Msgs Sent                    0     0
  13. Local Msgs Recv\'d                 0     66
  14. Distr Msgs Recv\'d                 0     0

  15. 11 rows selected.
没有用到并行,因为我们没有在回话上启用dml并行操作

启动dml并行                  

点击(此处)折叠或打开

  1. sh@TESTDB12>alter session enable parallel dml;


点击(此处)折叠或打开

  1. sh@TESTDB12>insert into little_sales
  2.   2 select * from sales;

  3. 918843 rows created.

  4. sh@TESTDB12>select * from v$pq_sesstat;

  5. STATISTIC                  LAST_QUERY SESSION_TOTAL
  6. ------------------------------ ---------- -------------
  7. Queries Parallelized                0     1
  8. DML Parallelized                    1     1
  9. DDL Parallelized                    0     0
  10. DFO Trees                           1     2
  11. Server Threads                      2     0        --这里说的是总共的并行进程数
  12. Allocation Height                   2     0        --这里说明每个表上有2个进程在做并行                               
  13. Allocation Width                    1     0
  14. Local Msgs Sent                  2105     66
  15. Distr Msgs Sent                     0     0
  16. Local Msgs Recv\'d                  8     66
  17. Distr Msgs Recv\'d                  0     0

  18. 11 rows selected.


这里并行最大的 parallel_max_servers是20                 


点击(此处)折叠或打开

  1. create table temp_channels
  2. parallel 5 as
  3. select * from sh.channels
  4. where channel_id in ('2','3','4');

点击(此处)折叠或打开

  1. sys@TESTDB12>alter system set parallel_max_servers=5;              --最大并行度设置成5

  2. System altered.

  3. sys@TESTDB12>alter system set parallel_adaptive_multi_user = false;

  4. System altered.

点击(此处)折叠或打开

  1. create table temp_sales nologging parallel 5 as
  2. select * from sh.sales
  3. where channel_id in ('2','3');

点击(此处)折叠或打开

  1. select count(*) from temp_sales s ,temp_channels c
  2. where (s.channel_id) = (c.channel_id);

  3.   COUNT(*)
  4. ----------
  5.   798353


点击(此处)折叠或打开

  1. sh@TESTDB12>select * from v$pq_sesstat;

  2. STATISTIC                      LAST_QUERY SESSION_TOTAL
  3. ------------------------------ ---------- -------------
  4. Queries Parallelized                    1     3
  5. DML Parallelized                        0     0
  6. DDL Parallelized                        0     3
  7. DFO Trees                               1     6
  8. Server Threads                          4     0             --4个并行
  9. Allocation Height                       2     0             --两张表
  10. Allocation Width                        1     0
  11. Local Msgs Sent                        88     611
  12. Distr Msgs Sent                         0     0
  13. Local Msgs Recv\'d                     88     611
  14. Distr Msgs Recv\'d                      0     0

点击(此处)折叠或打开

  1. alter system set parallel_max_servers = 20;



点击(此处)折叠或打开

  1. sh@TESTDB12>select * from v$pq_sesstat;

  2. STATISTIC                               LAST_QUERY SESSION_TOTAL
  3. ------------------------------ ---------- -------------
  4. Queries Parallelized                    1     4
  5. DML Parallelized                        0     0
  6. DDL Parallelized                        0     3
  7. DFO Trees                               1     7
  8. Server Threads                         10     0       --2张表总共启动并行数    
  9. Allocation Height                       5     0       --1张表的并行数
  10. Allocation Width                        1     0
  11. Local Msgs Sent                       223     834
  12. Distr Msgs Sent                         0     0
  13. Local Msgs Recv\'d                    223     834
  14. Distr Msgs Recv\'d                      0     0
数据仓库


性能调优


 使用结果池

结果集(result cache):只是把计算后的结果,放在shared pool中。         

点击(此处)折叠或打开

  1. idle>create user grc identified by grc
  2.   2 default tablespace users
  3.   3 temporary tablespace temp;

  4. User created.

  5. idle>grant connect , resource ,dba to grc;

  6. Grant succeeded.

  7. idle>conn grc/grc
  8. Connected.
  9. grc@TESTDB12>exec dbms_result_cache.flush;

  10. PL/SQL procedure successfully completed.

  11. grc@TESTDB12>create table cachejfv (c varchar2(500)) tablespace users;

  12. Table created.

  13. grc@TESTDB12>insert into cachejfv values(\'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\');

  14. grc@TESTDB12>insert into cachejfv select * from cachejfv;

  15. 2097152 rows created.                                  --插入4194304条数据。

  16. grc@TESTDB12>insert into cachejfv values ('b');
  17. grc@TESSDB12>commit;

  18. grc@TESTDB12>alter system flush buffer_cache;

点击(此处)折叠或打开

  1. grc@TESTDB12>show parameter result

  2. NAME                                        TYPE     VALUE
  3. ------------------------------------ ----------- ------------------------------
  4. client_result_cache_lag              big integer      3000
  5. client_result_cache_size             big integer      0
  6. result_cache_max_result                  integer      5
  7. result_cache_max_size                big integer      2080K
  8. result_cache_mode                         string      MANUAL
  9. result_cache_remote_expiration           integer      0

点击(此处)折叠或打开

  1. grc@TESTDB12>select /*+ result_cache q_name(Q1) */ count(*)                --不使用hint就不会用到结果集
  2.   2 from cachejfv c1 ,cachejfv c2 ,cachejfv c3 ,cachejfv c4,cachejfv c5
  3.   3 where c1.c ='b' and c2.c='b' and c3.c='b' and c4.c='b' and c5.c='b';

  4.   COUNT(*)
  5. ----------
  6.      1


  7. Execution Plan
  8. ----------------------------------------------------------
  9. Plan hash value: 2522916280

  10. --------------------------------------------------------------------------------------------------------
  11. |  Id | Operation                 | Name                       | Rows | Bytes | Cost (%CPU) | Time     |
  12. --------------------------------------------------------------------------------------------------------
  13. |   0 | SELECT STATEMENT          |                            | 1    | 1260  | 286T  (1)   |999:59:59 |
  14. |   1 |  RESULT CACHE             | 2czdyj48767d90j12kd0bvvbrd |      |       |             |          |
  15. |   2 |   SORT AGGREGATE          |                            | 1    | 1260  |             |          |
  16. |   3 |    MERGE JOIN CARTESIAN   |                            | 11T  | 12P   | 286T  (1)   |999:59:59 |
  17. |   4 |     MERGE JOIN CARTESIAN  |                            | 28G  | 25T   | 700G  (1)   |999:59:59 |
  18. |   5 |      MERGE JOIN CARTESIAN |                            | 68M  | 48G   | 1708M (1)   |999:59:59 |
  19. |   6 |       MERGE JOIN CARTESIAN|                            | 167K | 80M   | 4169K (1)   | 13:53:51 |
  20. |*  7 |        TABLE ACCESS FULL  | CACHEJFV                   | 410  | 100K  | 10146 (1)   | 00:02:02 |
  21. |   8 |        BUFFER SORT        |                            | 410  | 100K  | 4159K (1)   | 13:51:49 |
  22. |*  9 |         TABLE ACCESS FULL | CACHEJFV                   | 410  | 100K  | 10144 (1)   | 00:02:02 |
  23. |  10 |       BUFFER SORT         |                            | 410  | 100K  | 1708M (1)   |999:59:59 |
  24. |* 11 |        TABLE ACCESS FULL  | CACHEJFV                   | 410  | 100K  | 10144 (1)   | 00:02:02 |
  25. |  12 |      BUFFER SORT          |                            | 410  | 100K  | 700G  (1)   |999:59:59 |
  26. |* 13 |       TABLE ACCESS FULL   | CACHEJFV                   | 410  | 100K  | 10144 (1)   | 00:02:02 |
  27. |  14 |     BUFFER SORT           |                            | 410  | 100K  | 286T  (1)   |999:59:59 |
  28. |* 15 |      TABLE ACCESS FULL    | CACHEJFV                   | 410  | 100K  | 10144 (1)   | 00:02:02 |
  29. --------------------------------------------------------------------------------------------------------

  30. Predicate Information (identified by operation id):
  31. ---------------------------------------------------

  32.    7 - filter(\"C1\".\"C\"=\'b\')
  33.    9 - filter(\"C2\".\"C\"=\'b\')
  34.   11 - filter(\"C3\".\"C\"=\'b\')
  35.   13 - filter(\"C4\".\"C\"=\'b\')
  36.   15 - filter(\"C5\".\"C\"=\'b\')

  37. Result Cache Information (identified by operation id):
  38. ------------------------------------------------------

  39.    1 - column-count=1; dependencies=(GRC.CACHEJFV); attributes=(single-row); parameters=(nls); name=\"select /*+ result_cache q_name(Q1) */ count(*)
  40. from cachejfv c1 ,cachejfv c2 ,cachejfv c3 ,cachejfv c4,cachejfv c5
  41. where c1.c =\'\"


  42. Note
  43. -----
  44.    - dynamic sampling used for this statement (level=2)


  45. Statistics
  46. ----------------------------------------------------------
  47.      21 recursive calls
  48.      10 db block gets
  49.      358165 consistent gets
  50.      182445 physical reads
  51.      0 redo size
  52.     526 bytes sent via SQL*Net to client
  53.     523 bytes received via SQL*Net from client
  54.      2 SQL*Net roundtrips to/from client
  55.      4 sorts (memory)
  56.      0 sorts (disk)

点击(此处)折叠或打开

  1. 1 select type,status,name,object_no,row_count,row_size_avg
  2.   2* from v$result_cache_objects order by 1

  3. TYPE       STATUS NAME                               OBJECT_NO    ROW_COUNT  ROW_SIZE_AVG
  4. ---------- --------- ------------------------------ ---------- ------------ -------------
  5. Dependency Published GRC.CACHEJFV                        76977            0             0
  6. Result     Published select /*+ result_cache q_name          0            1             5
  7.            (Q1) */ count(*)
  8.            from cachejfv c1 ,cachejfv c2,cachejfv c3
  9.            ,cachejfv c4,cachejfv c5 where c1.C =
当表中有数据改变oracle会将那个结果集标记为invalid


点击(此处)折叠或打开

  1. grc@TESTDB12>exec dbms_result_cache.memory_report(detailed=>true);
  2. R e s u l t C a c h e M e m o r y    R e p o r t
  3. [Parameters]
  4. Block Size     = 1K bytes
  5. Maximum Cache Size = 2080K bytes (2080 blocks)
  6. Maximum Result Size = 104K bytes (104 blocks)
  7. [Memory]
  8. Total Memory = 168920 bytes [0.064% of the Shared Pool]
  9. ... Fixed Memory = 5352 bytes [0.002% of the Shared Pool]
  10. ....... Memory Mgr = 200 bytes
  11. ....... Cache Mgr = 208 bytes
  12. ....... Bloom Fltr = 2K bytes
  13. ....... State Objs = 2896 bytes
  14. ... Dynamic Memory = 163568 bytes [0.062% of the Shared Pool]
  15. ....... Overhead = 130800 bytes
  16. ........... Hash Table     = 64K bytes (4K buckets)
  17. ........... Chunk Ptrs     = 24K bytes (3K slots)
  18. ........... Chunk Maps     = 12K bytes
  19. ........... Miscellaneous = 28400 bytes
  20. ....... Cache Memory = 32K bytes (32 blocks)
  21. ........... Unused Memory = 30 blocks
  22. ........... Used Memory = 2 blocks
  23. ............... Dependencies = 1 blocks (1 count)
  24. ............... Results = 1 blocks
  25. ................... SQL = 1 blocks (1 count)

  26. PL/SQL procedure successfully completed.
如果表的数据一直放生变化那么可以把手动设置成自动。




DG

备份可以在备库上备份就可以啦



来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29812751/viewspace-1788285/ ,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-08-18

  • 博文量
    36
  • 访问量
    150737