Skip to Main Content
  • Questions
  • Sql Plan Managment (SPM) 12c - Evolve Procedure stuck on some SQL's

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, Alireza.

Asked: August 18, 2017 - 12:07 pm UTC

Last updated: August 19, 2017 - 12:09 am UTC

Version: 12.1.0.2.0

Viewed 1000+ times

You Asked

Hi Tom, we introduced SPM since 11g and now migrated to 12c (where SPM get envolved during the main. window)
Our evolve procedure stuck however on some certain statements so that after 4 hrs (during of the main window) the SPM EVOLVE get interrupted -> thus not the entire Baseleins get evolved ! (we are taliking about 136K baselines by a high transactional database!)

Several SRs didnt helped that we opened :-(

We are pretty confident (since we have monitored the running EVOLVE session severla times) that evolving (Parsing) of certain SQLs take so long time (and create LONG OPs to get terminated) that the other ones cannot get evolved in the mean time.
Alos we rae able (accoring to the 12c SPM new feature) to recognize and isolate the appropriate SQLs to not get evolved at all...
Unless you have other ideas or recommandationes !?

This is whta we seein the DBA_ADVISOR_TASKS view:

SELECT * FROM DBA_ADVISOR_TASKS WHERE task_name like '%SYS_AUTO_SPM_EVOLVE_TASK%';

SYS 57208 SYS_AUTO_SPM_EVOLVE_TASK Automatic SPM Evolve Task SPM Evolve Advisor 17.01.2016 08:21:18 18.08.2017 02:00:03 0 0 EXEC_84463 SPM EVOLVE 7 17.08.2017 22:00:06 18.08.2017 02:00:03 INTERRUPTED 0 0 0 0 ORA-13638: Der Benutzer hat den aktuellen Vorgang unterbrochen. AUTO FALSE TRUE 11 4


and this is our setting of advisor parameter for autom. evolve:

SELECT parameter_name, parameter_value
FROM dba_advisor_parameters
WHERE task_name = 'SYS_AUTO_SPM_EVOLVE_TASK'
AND parameter_value != 'UNUSED'
ORDER BY parameter_name;

ACCEPT_PLANS TRUE
DAYS_TO_EXPIRE UNLIMITED
DEFAULT_EXECUTION_TYPE SPM EVOLVE
EXECUTION_DAYS_TO_EXPIRE 30
JOURNALING INFORMATION
MODE COMPREHENSIVE
_SPM_VERIFY TRUE
TARGET_OBJECTS 1
TIME_LIMIT 2147483646


Thanks!
Alireza

and we said...

Hi Alireza,

The nightly SPM evolve task runs as part of the SQL Tuning task during the maintenance windows. By default, the task is given just 1 hour to complete with the SQL Tuning Advisor going first.

When the SPM evolve task begins, it compiles an ordered list of the unaccepted plans, to be examined during each maintenance window, using the following criteria:

LAST_VERIFIED
LAST_EXECUTED
COST
TIME OF CREATION

Plans that are unaccepted and have a value of NULL for their LAST_VERIFIED column go to the top of the list. Out of that group, plans are ordered based on the value in the LAST_EXECUTED column, then on the COST of the plans and finally on TIME OF CREATION, with the oldest ones going first.

In order to prevent a particular plan from ever being added to the evolve task list you need to do two things:

• Have a non-NULL value in the LAST_VERIFIED column
• Mark the plan as ACCEPTED

Depending on whether or not you consider the plan in question to be a good plan or bad plan will determine what approach you should take to prevent the plan from being added to the evolve task list.

If you don’t know if it’s a good plan or not, the safest approach would be to manually run the evolve task for the plan using the DBMS_SPM.EXECUTE_EVOLVE_TASK function. By manually running the task, you will remove the maintenance window time constraints and you can verify if the unaccepted plan is better than the existing plan or not.

Once the task completes the LAST_VERIFIED column will be updated and therefore no longer NULL. If the plan is accepted after the evolve task it will never become a candidate for the task again.

If however, the plan is not accepted after the task completes, then the plan will not be considered for the nightly evolve task for at least 30 days and then only if it’s only then if the SQL statement is active (LAST_EXECUTED attribute has been updated).


If you know that the problematic plan really is a good plan that you want to have accepted, you can manually accept the plan without having to run the verification part of the evolve process by using the old DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE function, with the VERIFY parameter set to NO. This will instantly accepted the new plan and update the LAST_VERIFIED column, which will remove the statement from the evolve task list forever.

variable evol_out clob
execute :evol_out := dbms_spm.evolve_sql_plan_baseline(sql_handle=>'SYS_SQL_edcedb30afeb8caa',
                                                            plan_name=>'SQL_PLAN_fvmqv62ryr35ac47b6be0'
                                                             verify=>’NO’);

select :evol_out from dual;


If you know for sure the problematic plan is a bad plan that you will never want used than you can take a two-step approach:

1. Manually accept the plan without verification using the DBMS_SPM.EVOLVE_SQL_PLAN_BASELINE function as described above
2. Then immediately mark the plan disabled by using the ALTER_SQL_PLAN_BASELINE Function as shown below

variable cnt number

exec :cnt := dbms_spm.alter_sql_plan_baseline( -
                 sql_handle        => 'SQL_293ebc02a81d5606', -
                 plan_name         => 'SQL_PLAN_2kgpw0an1uph654bc8843', -
                 attribute_name    => 'ENABLED', -
                 attribute_value   => 'NO');



Rating

  (2 ratings)

Is this answer out of date? If it is, please let us know via a Comment

Comments

A reader, August 19, 2017 - 3:26 pm UTC


Alireza, August 21, 2017 - 1:51 pm UTC

many thanks for your very useful hints.
However the evolve process (SYS_AUTO_SQL_TUNING_TASK) running in maint. Windows stuck still though ! we dont what or which SQL hangs there really ora/and on which step either ...

Is there any specific way to trace the eVOLVE process? to find this out?
We do have meanwhile over 1Mio baselines BUT among of theme actually only 10K (max.)are qualified to be evolved -->

select count(*) from DBA_SQL_PLAN_BASELINES a
where A.ACCEPTED ='NO'
and last_verified is null


count(*) --> 9743

Thank you!

More to Explore

Performance

Get all the information about database performance in the Database Performance guide.