Long parsing on Oracle 12.2 and the discovery of SQLT Xplore


Today I discovered a fantastic free tool from Oracle: SQLT Xplore!

At a client I had one query that took long time parsing. The tkprof result of the 10046 trace showed it took 5 seconds to parse:

call     count       cpu    elapsed       disk      query    current        rows
------- ------  -------- ---------- ---------- ---------- ----------  ----------
Parse        1      5.17       5.30          0          0          0           0
Execute      1      0.00       0.00          0          0          0           0
Fetch        1      0.00       0.00          0        665          0          26
------- ------  -------- ---------- ---------- ---------- ----------  ----------
total        3      5.17       5.30          0        665          0          26

Looking around I’ve noticed that disabling the cost based transformation:

ALTER SESSIONS SET "_optimizer_cost_based_transformation"=off;  

…the query was much faster to parse: only 0,5 seconds.

I’ve open an SR with the SQLT Xecute result, and after insisting the problem was not the execute but rather the parsing, the analyst said it was probably the non-public bug:

HI Miguel

The issue seems to be matching with an internal document and for some reason it is not yet published to the customers.

Query Parse is Taking Long time After DB Upgraded From 12102 To 12201 with CBQT ( Doc ID 2520631.1 )

Below is a snippet from the 10053 trace and we could see that in the CBQT , query is taking 25.86 seconds and the overall query time is 26.303 seconds.

TIMER: CBQT SU and CVM SEL$3D2C5B0A cpu: 25.367 sec elapsed: 25.864 sec >>>>>>>>>>>>>>>>
TIMER: SQL Optimization (Overall) SEL$FF489B46 cpu: 25.796 sec elapsed: 26.303 sec >>>>>>>>>>>>>>>>>

There is no patch available for this issue currently and the only option available is to set the parameter to 'off'.

I insisted if there was a better or other solution than disabling the cost based transformation and he suggested to run SQLT Xplore.

This tool tested 1847 optimizer parameters changes, bug fixes (more on Exadata) and simply gave an html output with the summary result, the different plans and timings:

But I found easier to check directly on the database, ordered by the best solution timing:

SELECT * FROM anjo.xplore_test WHERE plan_cost IS NOT NULL ORDER BY elapsed_time;

This showed me that with optimizer_features_enabled for any Oracle version 8i the parsing was much faster (and having the same results, important to check!), followed by using “_unnest_subquery” = FALSE or “_optimizer_unnest_all_subqueries” = FALSE.

To apply this, then the best is to use a SQL Patch if the query text is stable:

DECLARE
  l  VARCHAR2(32767);
BEGIN
  l := SYS.DBMS_SQLDIAG.create_sql_patch(
    sql_id    => 'dy8x4h4bratan',
    hint_text => q'[opt_param('optimizer_features_enable','8.1.3')]',
    name      => 'optimizer_813');
END;
/

Or add the change as a hint directly to the SQL:

select /*+ OPT_PARAM('_unnestsql_subquery','true') */
...

Here how to use SQL Xplorer.

Leave a comment

Your email address will not be published.