denrepo

OracleSQL tuning

SQL plan baselines and SQL profiles

What's pinning plans in this database. Baselines come with Enterprise Edition; SQL profiles are created by the SQL Tuning Advisor, which needs the Tuning Pack.

Not yet verified. How scripts are tested

ora-baselines.sql
1CLEAR COLUMNS2SET LINESIZE 180 PAGESIZE 100 TRIMOUT ON TAB OFF3COLUMN sql_handle HEADING "SQL HANDLE" FORMAT A224COLUMN plan_name  HEADING "PLAN NAME"  FORMAT A325COLUMN enabled    HEADING "ENABLED"    FORMAT A76COLUMN accepted   HEADING "ACCEPTED"   FORMAT A87COLUMN fixed      FORMAT A58COLUMN origin     FORMAT A289COLUMN created    FORMAT A1010COLUMN name       HEADING "PROFILE"    FORMAT A3211COLUMN category   FORMAT A1012COLUMN status     FORMAT A813COLUMN sql_text   HEADING "SQL"        FORMAT A60 TRUNCATE14 15SELECT sql_handle, plan_name, enabled, accepted, fixed, origin,16       TO_CHAR(created, 'YYYY-MM-DD') AS created17FROM dba_sql_plan_baselines18ORDER BY created DESC;19 20SELECT name, category, status,21       TO_CHAR(created, 'YYYY-MM-DD') AS created,22       DBMS_LOB.SUBSTR(sql_text, 60, 1) AS sql_text23FROM dba_sql_profiles24ORDER BY created DESC;

Save it as ora-baselines.sql and run it with SQL> @ora-baselines.

Open in denrepo

More Oracle scripts: SQL tuning