码迷,mamicode.com
首页 > 数据库 > 详细

Colored SQL--How to force the AWR to capture a specified SQL even if it is not the top one

时间:2014-11-24 11:53:56      阅读:199      评论:0      收藏:0      [点我收藏+]

标签:colored sql   awr snapshot   capture sql   dbms_workload_reposi   add_colored_sql   

This new feature doesn‘t paint the SQL statement in color; rather, it sort of marks it as "important."

Suppose you are troubleshooting a performance issue and you suspect a specific SQL statement contributing to the problem. You want the SQL statement to be captured in every Automatic Workload Repository (AWR) snapshot. But AWR snapshots do not capture all SQL statements; just the top ones. How can you force a specific SQL to be captured, regardless of its inclusion in the top SQLs?

The procedure add_colored_sql() in the package dbms_workload_repository marks the SQL as "colored", or important enough to be captured in every AWR snapshot regardless of whether the SQL is in top SQLs. First, identify the SQL statement and then get its SQL_ID. To color it, use:

 
begin
  dbms_workload_repository.add_colored_sql(
     sql_id => ‘ff15115dvgukr‘
  );
end;


To find out which SQLs have been colored, you can query the AWR table WRM$_COLORED_SQL:


SQL> SELECT * FROM wrm$_colored_sql;

DBID  SQL_ID  OWNER      CREATE_TI
---------- ------------- ----------      --------
2965581158 ff15115dvgukr 1 05-APR-08


Thereafter the SQL statement with ID ff15115dvgukr will be captured in every snapshot, even if it‘s not in the top SQL statements. (Of course, the SQL must be present in the library cache to be captured in the AWR snapshots.)

But what if the SQL ceases to be that colorful—that is, not important enough to be captured? You can turn it off by issuing the obverse of the procedure.

begin
  dbms_workload_repository.remove_colored_sql(
    sql_id => ‘ff15115dvgukr‘
  );
end;


This feature is extremely useful when you want to focus on a specific SQL in your tuning exercises.


For more information, Pls refer to http://www.oracle.com/technetwork/articles/sql/11g-misc-091388.html#top

Colored SQL--How to force the AWR to capture a specified SQL even if it is not the top one

标签:colored sql   awr snapshot   capture sql   dbms_workload_reposi   add_colored_sql   

原文地址:http://blog.csdn.net/xiangsir/article/details/41441969

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!