11.07.2015 Views

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

Oracle Database 11 g - Online Public Access Catalog

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

208 CHAPTER 4 ■ PERFORMANCE MANAGEMENTCapturing SQL Plan BaselinesThe first phase involves capturing the SQL plan baselines. To support SPM and the performanceverification of newly evolved execution plans, the optimizer maintains a plan history for eachrepeatable SQL statement containing the different execution plans generated for that statement.The optimizer considers a SQL statement repeatable if the database parses or executesthat statement multiple times after the optimizer logs the statement in the SQL statement logthat it maintains.You can load the SQL plan outlines automatically or use manual bulk-loading procedures.First we’ll discuss the automatic approach to creating and maintaining plan history for SQLstatements, using the optimizer-provided data. Then we’ll show how to do this manually.Automatic SQL Plan CaptureYou can enable automatic loading of SQL plan baselines by setting the initialization parameteroptimizer_capture_plan_baselines to true, as shown here:SQL> alter system set optimizer_capture_sql_plan_baselines=true;System altered.The default value of the optimizer_capture_sql_plan_baselines parameter is false, meaningautomatic plan capture is turned off by default. By setting the parameter’s value to true in theparameter file, or with the alter system or alter session statement, you let the database automaticallystart recognizing repeatable SQL statements and create a plan history for them.The database uses the optimizer details about each SQL statement to reproduce theexecution plan for it. The first plan for each SQL statement is marked for use by the optimizer.At this point, both plan history and the SQL plan baseline are identical, since there’s only asingle SQL statement to consider. All new plans that the optimizer generates subsequently fora SQL statement become part of the plan history. During the final SQL plan baseline evolutionphase, the database will add to the SQL plan baseline any plan that’s verified not to lead to aperformance regression.■Note If you manually load plans directly from the cursor cache, those plans are automatically marked asSQL baseline plans by default.Manual SQL Plan LoadingIn addition to this automatic tracking of repeatable SQL statements, you can also manuallyseed plans for a set of SQL statements (SQL tuning set). You can supply the SQL plans as analternative or in addition to the automatic capture of SQL by the database. An importantdistinction between automatically capturing SQL plans and manually loading SQL plans is thatthe database adds all manually loaded plans to a SQL plan baseline as accepted plans, withoutsubjecting them to verification for performance.You can use the new DBMS_SPS package to load SQL plans directly into a SQL plan baseline.You can use a cursor cache as the source of the SQL plans or load the plans from SQL tuningsets and AWR snapshots. In the following example, we show how to load SQL plans manually

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!