Automatic SQL Tuning in Oracle Database 11g
Automatic SQL Tuning in Oracle Database 11g Release 1
As part of Automatic SQL Tuning, Oracle 11g automatically runs the SQL Tuning Advisor against high impact SQL statements during maintenance windows. This process involves the following steps:
- AWR statistics are used to compile an ordered list of the SQL statements with the greatest performance impact on the system, where the impact is the sum of the CPU and I/O times for the statement during the past week. The list excludes statements that are inherently less tunable, such as recently (within a month) tuned recursive statements, parallel queries, DML, DDL and SQL statements whose performance problems are caused by concurrency issues.
- The SQL tuning advisor is run against each statement in turn. The outcome may include both SQL profiles and other recommendations.
- Suggested SQL profiles are performance tested, and those that result in at least a threefold improvement are accepted if the ACCEPT_SQL_PROFILES parameter is set to TRUE, or reported if it is set to FALSE.
- The accepted SQL profiles are optionally implemented . Several factors many prevent SQL profiles from being implemented automatically, including stale optimizer statistics of dependent objects. The TYPE column of the DBA_SQL_PROFILES view indicates if SQL profiles are created manually (MANUAL) or automatically (AUTO-TUNE).
The ENABLE and DISABLE procedures of the DBMS_AUTO_TASK_ADMIN package control whether automatic SQL tuning is included in the automated maintenance tasks.
-- Enable BEGIN DBMS_AUTO_TASK_ADMIN.enable( client_name => 'sql tuning advisor', operation => NULL, window_name => NULL); END; / -- Disable BEGIN DBMS_AUTO_TASK_ADMIN.disable( client_name => 'sql tuning advisor', operation => NULL, window_name => NULL); END; /
It is also indirectly disabled by setting the STATISTICS_LEVEL parameter to BASIC, as this stops automatic statistics gathering by the AWR.
The SET_TUNING_TASK_PARAMETER procedure of the DBMS_SQLTUNE package controls the behavior. of the SQL tuning advisor. The parameters specifically for the automatic runs include:
- ACCEPT_SQL_PROFILES - Automatically accept SQL profiles (default FALSE).
- MAX_SQL_PROFILES_PER_EXEC - The maximum number of SQL profiles automatically implemented per run (default 20).
- MAX_AUTO_SQL_PROFILES - The maximum number of automatic SQL profiles allowed on the system (default 10000).
The current parameter values are displayed using the %_ADVISOR_PARAMETERS views.
COLUMN parameter_value FORMAT A30 SELECT parameter_name, parameter_value FROM dba_advisor_parameters WHERE task_name = 'SYS_AUTO_SQL_TUNING_TASK' AND parameter_name IN ('ACCEPT_SQL_PROFILES', 'MAX_SQL_PROFILES_PER_EXEC', 'MAX_AUTO_SQL_PROFILES'); PARAMETER_NAME PARAMETER_VALUE ------------------------------ ------------------------------ ACCEPT_SQL_PROFILES FALSE MAX_SQL_PROFILES_PER_EXEC 20 MAX_AUTO_SQL_PROFILES 10000 3 rows selected. SQL>
The following code shows how the SET_TUNING_TASK_PARAMETER procedure is used to turn on acceptance of automatically generated SQL profiles.
BEGIN DBMS_SQLTUNE.set_tuning_task_parameter( task_name => 'SYS_AUTO_SQL_TUNING_TASK', parameter => 'ACCEPT_SQL_PROFILES', value => 'TRUE'); END; /
The REPORT_AUTO_TUNING_TASK function of the DBMS_SQLTUNE package returns a CLOB containing a report from the specified automatic tuning task. Setting the BEGIN_EXEC and END_EXEC parameters to NULL produces a report from the most recent execution.
VARIABLE l_report CLOB; BEGIN :l_report := DBMS_SQLTUNE.report_auto_tuning_task( begin_exec => NULL, end_exec => NULL, type => DBMS_SQLTUNE.type_text, -- 'TEXT' level => DBMS_SQLTUNE.level_typical, -- 'TYPICAL' section => DBMS_SQLTUNE.section_all, -- 'ALL' object_id => NULL, result_limit => NULL); END; / SET LONG 1000000 PRINT :l_report L_REPORT -------------------------------------------------------------------------------- GENERAL INFORMATION SECTION ------------------------------------------------------------------------------- Tuning Task Name : SYS_AUTO_SQL_TUNING_TASK Tuning Task Owner : SYS Workload Type : Automatic High-Load SQL Workload Execution Count : 31 Current Execution : EXEC_1_25 Execution Type : TUNE SQL Scope : COMPREHENSIVE Global Time Limit(seconds) : 3600 Per-SQL Time Limit(seconds) : 1200 Completion Status : COMPLETED Started at : 01/16/2008 22:00:06 Completed at : 01/16/2008 22:00:46 Number of Candidate SQLs : 0 Cumulative Elapsed Time of SQL (s) : 0 ------------------------------------------------------------------------------- SQL>
As you can see from the above report, this was run against a very quiet system, so there were no candidate SQL statements to process. If this were run against a more active system, you might expect the report to contain the following sections:
- General information - High-level information about the SQL tuning task.
- Summary - A summary of the SQL statements tuned during the task, including the estimated benefit associated with the tuning operation.
- Tuning finding - Information about findings, acceptance of the profile, implementation of the profile, and detailed execution statistics for each analyzed statement.
- Explain plans - The old and new execution plans for each analyzed statement.
- Errors - Any errors encountered during the task.
For more information see:
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/195110/viewspace-764493/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Automatic Diagnostic Repository (ADR) in Oracle Database 11g Release 1 (ADRCI)OracleDatabase
- Automatic Diagnostic Repository (ADR) with Oracle Net for 11gOracle
- Oracle 11g DG新特性--Automatic block repairOracleBloCAI
- Oracle SQL優化之sql tuning advisorOracleSQL優化
- Tuning CPU 100% in Oracle 11g rac-20220215Oracle
- oracle SQL最佳化器SQL Tuning Advisor (STA)OracleSQL
- Oracle 11 sql tuning advisor sql access advisor關閉以及job檢視與停止OracleSQL
- Oracle自帶工具sql優化集-SQL Tuning Advisor (使用心得體會)OracleSQL優化
- SQL Access Advisor、SQL Tuning Advisor 測試SQL
- 使用sql tuning advisor最佳化sqlSQL
- Oracle 12c Automatic ReoptimizationOracle
- Oracle優化案例-關閉auto space advisor和sql tuning advisor(十九)Oracle優化SQL
- Oracle 11g新特新--SQL Test Case BuilderOracleSQLUI
- oracle.Performance.Tuning筆記OracleORM筆記
- Oracle Advanced Performance Tuning Scripts(轉)OracleORM
- 【OCP最新題庫解析(052)--題9】You want to install Oracle 11g databaseOracleDatabase
- ORACLE database vaultOracleDatabase
- Oracle clone databaseOracleDatabase
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- [20191112]SQL Tuning by adding column alias (2).txtSQL
- SQL Database for Modern DevelopersSQLDatabaseDeveloper
- Oracle Performance Tuning 11g2 (2)OracleORM
- 2.10.3 使用 Oracle Automatic Storage Management (Oracle ASM) 克隆資料庫OracleASM資料庫
- Oracle Database Scheduler整理OracleDatabase
- Oracle Physical Database LimitsOracleDatabaseMIT
- Oracle Tuning (Oracle 效能調整)的一些總結(轉)Oracle
- Oracle 12.2 使用Database Link優化Standby Database WorkloadOracleDatabase優化
- Oracle之11g DataGuardOracle
- Oracle Tuning (Oracle 效能調整)的一些總結(轉)2Oracle
- indexedDB替代Web SQL Database原因IndexWebSQLDatabase
- Oracle 19c Concepts(01):Introduction to Oracle DatabaseOracleDatabase
- Oracle 19c Concepts(13):Oracle Database InstanceOracleDatabase
- Oracle OCP(35):Database 安裝OracleDatabase
- oracle 10g flashback databaseOracle 10gDatabase
- Oracle DG Standby Database型別OracleDatabase型別
- Oracle DG建立Physical Standby DatabaseOracleDatabase
- Oracle DG建立Logical Standby DatabaseOracleDatabase
- Oracle 11G 安裝文件Oracle
- benchmark 壓測Oracle 11gOracle