SQL Access Advisor(zt)
SQL Access Advisor in Oracle Database 10g
The SQL Access Advisor makes suggestions about indexes and materialized views which might improve system performance. This article describes how to use the SQL Access Advisor in Oracle 10g.
Enterprise Manager
The SQL Access Advisor is accessible from Enterprise Manager. Specific reports can be produced by clicking on the "Advisor Central" link, then the "SQL Access Advisor" link. The resulting page allows you to create a workload and an SQL Access Advisor task. Once the task has completed you can view information about the findings and recommendations.
DBMS_ADVISOR
The DBMS_ADVISOR package can be used to create and execute any advisor tasks, including SQL Access Advisor tasks. The following example shows how it is used to create, execute and display a typical SQL Access Advisor script. for the current workload:
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 SQL Access 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; IF l_num_found = 0 THEN DBMS_ADVISOR.create_sqlwkld(workload_name => l_wkld_name); END IF; -- 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; IF l_num_found = 0 THEN DBMS_ADVISOR.add_sqlwkld_ref( task_name => l_taskname, workload_name => l_wkld_name); END IF; -- 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 resulting script. 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 command should be adjusted to allow the whole script. to be displayed.
Quick Tune
If you just want to tune an individual statement you can use the QUICK_TUNE procedure as follows:
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 correct task name specified.
Related Views
The following views can be used to display the SQL Access Advisor output without using Enterprise Manager or the get_task_script function:
- DBA_ADVISOR_TASKS - Basic information about existing tasks.
- DBA_ADVISOR_LOG - Status information about existing tasks.
- DBA_ADVISOR_FINDINGS - Findings identified for an existing task.
- DBA_ADVISOR_RECOMMENDATIONS - Recommendations for the problems identified by an existing task.
For further information see:
Hope this helps. Regards Tim...
http://www.oracle-base.com/articles/10g/SQLAccessAdvisor10g.php
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/756652/viewspace-442204/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SQL Access Advisor!SQL
- SQL Access Advisor 概要SQL
- SQL Access Advisor 與SQL Tuning AdvisorSQL
- SQL Access Advisor、SQL Tuning Advisor 測試SQL
- sql tuning advisor和sql access advisor區別SQL
- 手工執行sql tuning advisor和sql access advisorSQL
- 使用dbms_advisor來執行sql access advisorSQL
- SQL Access Advisor的 DBMS_ADVISOR.QUICK_TUNE 使用SQLUI
- Oracle 11 sql tuning advisor sql access advisor關閉以及job檢視與停止OracleSQL
- Introduction to SQL Tuning Advisor zt自ITPUBSQL
- 在EM中使用SQL Access Advisor(SQL訪問建議)優化SQLSQL優化
- Oracle OCP IZ0-053 Q232(sql access advisor)OracleSQL
- Oracle OCP 1Z0 053 Q123(SQL Access Advisor)OracleSQL
- SQL Repair AdvisorSQLAI
- SQL TUNING ADVISORSQL
- SQL Tuning Advisor簡介SQL
- 使用sql tuning advisor最佳化sqlSQL
- Oracle SQL優化之sql tuning advisorOracleSQL優化
- oracle實用sql(3)--sql tuning advisorOracleSQL
- access 轉 sql 之一SQL
- sql tuning advisor(STA) 建議 建立sql profileSQL
- Oracle SQL優化之sql tuning advisor(STA)OracleSQL優化
- sql tuning set/sql tuning advisor(待完善)SQL
- zt_Segment Advisor監控物件的碎片程度並回收物件
- Sql Tuning Advisor 使用方法SQL
- 深入瞭解SQL Tuning AdvisorSQL
- SQL Tuning Advisor : dbms_sqltuneSQL
- oracle實用sql(4)--undo advisorOracleSQL
- oracle實用sql(2)--segment advisorOracleSQL
- SQL Tuning Advisor使用例項SQL
- oracle SQL最佳化器SQL Tuning Advisor (STA)OracleSQL
- Oracle SQL最佳化之sql tuning advisor(STA)OracleSQL
- ORACLE SQL TUNING ADVISOR 使用方法OracleSQL
- Guideline of SQL Tuning AdvisorGUIIDESQL
- Oracle優化案例-關閉auto space advisor和sql tuning advisor(十九)Oracle優化SQL
- SQL Server專題 [zt]SQLServer
- sql mode 型別(ZT)SQL型別
- 使用SQL Profile及SQL Tuning Advisor固定執行計劃SQL