如何驗證SQL PROFILE的性能?

發表于:2013-10-10來源:IT博客大學習作者:Maclean Liu點擊數: 標簽:SQL PROFILE
10g以后的sql tuning advisor(可以通過Enterprise Manager或DBMS_SQLTUNE包訪問)會給出對于SQL的建議包括以下四種:

  10g以后的sql tuning advisor(可以通過Enterprise Manager或DBMS_SQLTUNE包訪問)會給出對于SQL的建議包括以下四種:

  1. 收集最新的統計信息

  2. 徹底重構該SQL語句

  3. 創建推薦的索引

  4. 啟用SQL TUNING ADVISOR找到的SQL PROFILE

  這里我們要注意的是在production環境中顯然不可能讓我們在沒有充分測試的前提下隨意為SQL接受一個PROFILE,因為這可能為本來就性能糟糕而需要調優的系統引來變化。 但是如果恰巧沒有合適的TEST環境,而你的SQL PROFILE又可能是性能壓力的救命稻草時,我們可以使用以下方法在production環境中局部測試SQL PROFILE,僅在session級別生效:

  Oracle Database 12c Enterprise Edition Release 12.1.0.0.2 - 64bit Beta

  With the Partitioning, OLAP, Data Mining and Real Application Testing options

  SQL> create table profile_test tablespace users as select * from dba_objects;

  Table created.

  SQL> create index ix_objd on profile_test(object_id);

  Index created.

  SQL> set linesize 200 pagesize 2000

  SQL> exec dbms_stats.gather_table_stats('','PROFILE_TEST');

  PL/SQL procedure successfully completed.

  SQL> set autotrace traceonly;

  SQL> select /*+ FULL( profile_test) */ * from profile_test where object_id=5060;

  Execution Plan

  ----------------------------------------------------------

  Plan hash value: 663678050

  ----------------------------------------------------------------------------------

  | Id | Operation | Name | Rows | Bytes | Cost (%CPU)| Time |

  ----------------------------------------------------------------------------------

  | 0 | SELECT STATEMENT | | 1 | 113 | 408 (1)| 00:00:01 |

  |* 1 | TABLE ACCESS FULL| PROFILE_TEST | 1 | 113 | 408 (1)| 00:00:01 |

  ----------------------------------------------------------------------------------

  Predicate Information (identified by operation id):

  ---------------------------------------------------

  1 - filter("OBJECT_ID"=5060)

  Statistics

  ----------------------------------------------------------

  0 recursive calls

  0 db block gets

  1471 consistent gets

  0 physical reads

  0 redo size

  1779 bytes sent via SQL*Net to client

  543 bytes received via SQL*Net from client

  2 SQL*Net roundtrips to/from client

  0 sorts (memory)

  0 sorts (disk)

  1 rows processed

  f3v7dxj4bggvq

  Tune the sql

  ~~~~~~~~~~~~

  GENERAL INFORMATION SECTION

  -------------------------------------------------------------------------------

  Tuning Task Name : TASK_226

  Tuning Task Owner : SYS

  Workload Type : Single SQL Statement

  Scope : COMPREHENSIVE

  Time Limit(seconds): 1800

  Completion Status : COMPLETED

  Started at : 11/30/2012 13:13:27

  Completed at : 11/30/2012 13:13:30

  -------------------------------------------------------------------------------

  Schema Name : SYS

  Container Name: CDB$ROOT

  SQL ID : f3v7dxj4bggvq

  SQL Text : select /*+ FULL( profile_test) */ * from profile_test where

  object_id=5060

  -------------------------------------------------------------------------------

  FINDINGS SECTION (1 finding)

  -------------------------------------------------------------------------------

  1- SQL Profile Finding (see explain plans section below)

  --------------------------------------------------------

  A potentially better execution plan was found for this statement.

  Recommendation (estimated benefit: 99.79%)

  ------------------------------------------

  - Consider accepting the recommended SQL profile.

  execute dbms_sqltune.accept_sql_profile(task_name => 'TASK_226',

  task_owner => 'SYS', replace => TRUE);

  Validation results

  ------------------

  The SQL profile was tested by executing both its plan and the original plan

  and measuring their respective execution statistics. A plan may have been

  only partially executed if the other could be run to completion in less time.

  Original Plan With SQL Profile % Improved

  ------------- ---------------- ----------

  Completion Status: COMPLETE COMPLETE

  Elapsed Time (s): .005407 .000034 99.37 %

  CPU Time (s): .004599 0 100 %

  User I/O Time (s): 0 0

  Buffer Gets: 1470 3 99.79 %

原文轉自:http://blogread.cn/it/article/6041

国产97人人超碰caoprom_尤物国产在线一区手机播放_精品国产一区二区三_色天使久久综合给合久久97