您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

Oracle SQL Access Advisor 说明

2024/4/26 21:07:23发布15次查看
欢迎进入oracle社区论坛,与200万技术人员互动交流 >>进入 --task recommendation 是一个范围,从简单的建议到复杂的解决方案。当advisortask 执行时,sql access advisor 会仔细分析收集数据和用户定义的参数。 1.3.4 viewand implement the recommendation
欢迎进入oracle社区论坛,与200万技术人员互动交流 >>进入
    --task recommendation 是一个范围,从简单的建议到复杂的解决方案。当advisortask 执行时,sql access advisor 会仔细分析收集数据和用户定义的参数。
    1.3.4   viewand implement the recommendations
    you can view therecommendations from sql access advisor in either of the following ways:
    --可以使用如下2种方法来查看recommendation的内容:
    (1)using thecatalog views
    (2)generating ascript using the dbms_advisor.get_task_script procedure
    in enterprisemanager, you may display the recommendations after sql access advisor processhas completed. see viewingrecommendations for a description of using the catalog views toview the recommendations. see generatingsql scripts to see how to create a script.
    --在oem中,在sql access advisor 进程处理完毕后会自动显示recommendation。
    you need notaccept all recommendations. you can mark the ones to be included in therecommendation script. however, when base table partitioning is recommended,some recommendations depend on others. for example, you cannot implement alocal index if you do not also implement the partitioning recommendation on theindex base table.
    the final stepis then implementing the recommendations and verifying that query performancehas improved.
    1.3.5 sqlaccess advisor repository
    all theinformation needed and generated by sql access advisor resides in the advisorrepository, which is a part of the database dictionary. the benefits of usingthe repository are that it:
    --advisor 生成的所有信息都存放在advisor repository中,其是数据字典的一部分,使用repository有如下好处:
    (1)    collects a complete workloadfor sql access advisor.
    (2)    supports historical data.
    (3)    is managed by the server.
    1.3.6 使用sqlaccess advisor需要的权限
    you must have the advisor privilege tomanage or use sql access advisor. when processing a workload, sql accessadvisor attempts to validate each statement to identify table and columnreferences. the database achieves validation by processing each statement as ifit were being executed by the statement's original user.
    --必须需要有advisor权限
    if the user doesnot have select privileges to a particular table, then sql accessadvisor bypasses the statement referencing the table. this behavior can causemany statements to be excluded from analysis. if sql access advisor excludesall statements in a workload, then the workload is invalid. sql access advisorreturns the following message:
    qsm-00774, thereare no sql statements to process for task task_name
    --必须需要有指定表的select 的权限,否则会报qsm-774错误。
    to avoid missingcritical workload queries, the current database user must have select privilegeson the tables targeted for materialized view analysis. for these tables, these select privilegescannot be obtained through a role.
    additionally,you must have the administer sql tuning set privilege to create andmanage workloads in sql tuning set objects. to run the advisor on sql tuningsets owned by other users, you must have the administer any sql tuning set privilege.
    --还需要 administer sql tuning set的权限来创建和管理workload。
    二。手工生成sqlaccess advisor 示例
    from:
    http://www.oracle-base.com/articles/10g/sqlaccessadvisor10g.php
    2.1 dbms_advisor
    the dbms_advisor packagecan be used to create and execute any advisor tasks, including sql accessadvisor tasks. the following example shows how it is used to create, executeand display a typical sql access advisor script for the current workload.
    --dbms_advisor 包可以用来创建和执行advisor 任务。
    declare
    l_taskname     varchar2(30)  := 'test_sql_access_task';
    l_task_desc    varchar2(128)  := 'test sql access task';
    l_wkld_name    varchar2(30)   := 'test_work_load';
    l_saved_rows   number         := 0;
    l_failed_rows  number         := 0;
    l_num_found    number;
    begin
    -- create an sqlaccess advisor task.
    dbms_advisor.create_task (
    advisor_name => dbms_advisor.sqlaccess_advisor,
    task_name    => l_taskname,
    task_desc    => l_task_desc);
    -- reset the task.
    dbms_advisor.reset_task(task_name => l_taskname);
    -- create a workload.
    select count(*)
    into   l_num_found
    from   user_advisor_sqlw_sum
    where  workload_name =l_wkld_name;
    ifl_num_found = 0 then
    dbms_advisor.create_sqlwkld(workload_name => l_wkld_name);
    endif;
    -- link the workload to the task.
    select count(*)
    into   l_num_found
    from   user_advisor_sqla_wk_map
    where  task_name     = l_taskname
    and    workload_name =l_wkld_name;
    ifl_num_found = 0 then
    dbms_advisor.add_sqlwkld_ref(
    task_name     => l_taskname,
    workload_name => l_wkld_name);
    endif;
    -- set workload parameters.
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name, 'action_list',dbms_advisor.advisor_unused);
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name,'module_list', dbms_advisor.advisor_unused);
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name, 'sql_limit',dbms_advisor.advisor_unlimited);
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name, 'order_list', 'priority,optimizer_cost');
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name, 'username_list',dbms_advisor.advisor_unused);
    dbms_advisor.set_sqlwkld_parameter(l_wkld_name, 'valid_table_list',dbms_advisor.advisor_unused);
    dbms_advisor.import_sqlwkld_sqlcache(l_wkld_name, 'replace', 2,l_saved_rows, l_failed_rows);
    -- set task parameters.
    dbms_advisor.set_task_parameter(l_taskname, '_mark_implementation','false');
    dbms_advisor.set_task_parameter(l_taskname, 'execution_type','index_only');
    dbms_advisor.set_task_parameter(l_taskname, 'mode', 'comprehensive');
    dbms_advisor.set_task_parameter(l_taskname, 'storage_change',dbms_advisor.advisor_unlimited);
    dbms_advisor.set_task_parameter(l_taskname, 'dml_volatility', 'true');
    dbms_advisor.set_task_parameter(l_taskname, 'order_list','priority,optimizer_cost');
    dbms_advisor.set_task_parameter(l_taskname, 'workload_scope','partial');
    dbms_advisor.set_task_parameter(l_taskname, 'def_index_tablespace',dbms_advisor.advisor_unused);
    dbms_advisor.set_task_parameter(l_taskname, 'def_index_owner',dbms_advisor.advisor_unused);
    dbms_advisor.set_task_parameter(l_taskname, 'def_mview_tablespace',dbms_advisor.advisor_unused);
    dbms_advisor.set_task_parameter(l_taskname, 'def_mview_owner', dbms_advisor.advisor_unused);
    -- execute the task.
    dbms_advisor.execute_task(task_name => l_taskname);
    end;
    /
    -- display the resultingscript.
    set long 100000
    set pagesize 50000
    select dbms_advisor.get_task_script('test_sql_access_task') as script from  dual;
    set pagesize 24
    the value for the set long commandshould be adjusted to allow the whole script to be displayed.
    在我测试环境上的输入结果如下:
    pl/sql procedure successfully completed.
    script
    --------------------------------------------------------------------------------
    rem  sql accessadvisor: version 10.2.0.4.0 - production
    rem
    rem  username:        sys
    rem  task:            test_sql_access_task
    rem  executiondate:  31/01/2012 21:50
    rem
    create bitmap index qsoa.data_oa_message_idx$$_167f0001
    onqsoa.data_oa_message
    (mess_type)
    computestatistics;
    create indexzhaoka.cfg_game_area_s_idx$$_167f0004
    on zhaoka.cfg_game_area_server
    (area_id,area_name,server_id,server_name)
    computestatistics;
    …
    2.2 quick tune
    if you just wantto tune an individual statement you can use the quick_tune procedureas follows.
    --如果仅仅是调整一个独立的语句,可以使用quick_tune过程:
    begin
    dbms_advisor.quick_tune(
    advisor_name => dbms_advisor.sqlaccess_advisor,
    task_name    =>'emp_quick_tune',
    attr1        => 'select e.*from emp e where upper(e.ename) = ''smith''');
    end;
    /
    any recommendations can then be displayed using the previous query with the correcttask name specified.
    查询输出结果和之前的一样,使用:
    select dbms_advisor.get_task_script(‘emp_quick_tune’) fromdual;
    2.3 related views
    the followingviews can be used to display the sql access advisor output without usingenterprise manager or the get_task_script function:
    --可以使用以下视图来查看advisor的输出:
    (1)    dba_advisor_tasks:basic information about existingtasks.
    (2)    dba_advisor_log :status information about existingtasks.
    (3)    dba_advisor_findings : findings identified for anexisting task.
    (4)    dba_advisor_recommendations : recommendations for the problemsidentified by an existing task.
  [1] [2]
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product