Striving for Optimal Performance
  • Home
  • Blog
    • Archive
    • Categories
  • Troubleshooting Oracle Performance
    • Description
    • Structure
    • Table of Contents
    • Forewords
    • Reviews
    • Downloadable Files
    • Addenda and Errata
  • Publications
  • Public Appearances
    • Past Public Appearances
  • Contact
  • Search
  • About

Monthly archives for August, 2008

Long Parses

Aug31
2008
6 Comments Written by Christian Antognini

From time to time I have to fight against long parses. In this post I would like to share with you what happened to a customer of mine while upgrading from 9.2.0.7 to 10.2.0.3 (10.2.0.4 was not yet available at that time).

The parse of a complex SQL statement took 5 seconds in 9.2.0.7. Not very fast… But, for a report that is rarely executed, it is not a disaster. The problem was that after upgrading to 10.2.0.3 the parse time when up to more than one hour! Of course:

  • It was no longer acceptable.
  • The problem was caused by a bug (in 10.2.0.4 the parse lasts 20 seconds).

In case of long parses that are executed only a few times as in this case, it is usually not possible to avoid the parse. In fact, the SQL statement must be parsed at least once. In addition, if the SQL statement is rarely executed, a hard parse is probably inevitable because the cursor will be aged out of the library cache between executions. This is especially true if no bind variables are used. Therefore, the only possible solution is to reduce the parse time itself. What causes long parse times? Commonly, they’re caused by the query optimizer evaluating too many different execution plans. This means that to shorten the parse times, you must reduce the number of evaluated execution plans. This is generally possible only by forcing an execution plan through hints or stored outlines.

In this case after creating a stored outline the parsing time went down to one second. However, the solution (workaround) implemented in this case was another one…

A careful comparison of the query optimizer’s configuration of both databases pointed out that the 9.2.0.7 was running with the following undocumented parameters set (it goes without saying that nobody remembered why…):

  • _b_tree_bitmap_plans = FALSE
  • _new_initial_join_orders = FALSE

By setting these two undocumented parameters in 10.2.0.3 the parse time when down to 18 seconds. The customer got the consent from Oracle Support to set them in production and, therefore, so they did.

Posted in 10gR2, 9iR2, Bug, Query Optimizer

TOP: Downloadable Files Are Available

Aug21
2008
Leave a Comment Written by Christian Antognini

This is a short note to inform that the scripts of TOP are available here. Please, do not hesitate to get in touch with me in case of any problem with them. Happy testing!

Posted in TOP

SQL Profiles in the Data Dictionary

Aug19
2008
4 Comments Written by Christian Antognini

In the paper SQL Profiles (page 22) I described the data dictionary tables where the hints belonging to SQL profiles are stored. For example, with the following query it is possible to display the hints associated to the SQL profile named opt_estimate.

SQL> SELECT attr_val
  2  FROM sys.sqlprof$ p, sys.sqlprof$attr a
  3  WHERE p.sp_name = 'opt_estimate'
  4  AND p.signature = a.signature
  5  AND p.category = a.category;

ATTR_VAL
---------------------------------------------------------------------------------
OPT_ESTIMATE(@"SEL$1", JOIN, ("T"@"SEL$1", "CH"@"SEL$1"), SCALE_ROWS=276.7754079)
OPT_ESTIMATE(@"SEL$1", TABLE, "CH"@"SEL$1", SCALE_ROWS=40.15499105)

As of Oracle Database 11g the previous query can no longer be used. In fact, the data dictionary has been changed. The tables SQLPROF$ and SQLPROF$ATTR no longer exist. As of Oracle Database 11g the information is stored in the tables SQLOBJ$ and SQLOBJ$DATA. The following query shows how to query the new tables. Note that since hints are stored in XML format, a conversion is necessary to have a readable output.

SQL> SELECT extractValue(value(h),'.') AS hint
  2  FROM sys.sqlobj$data od, sys.sqlobj$ so,
  3  table(xmlsequence(extract(xmltype(od.comp_data),'/outline_data/hint'))) h
  4  WHERE so.name = 'opt_estimate'
  5  AND so.signature = od.signature
  6  AND so.category = od.category
  7  AND so.obj_type = od.obj_type
  8  AND so.plan_id = od.plan_id;

HINT
---------------------------------------------------------------------------------
OPT_ESTIMATE(@"SEL$1", TABLE, "CH"@"SEL$1", SCALE_ROWS=39.20843548)
OPT_ESTIMATE(@"SEL$1", JOIN, ("T"@"SEL$1", "CH"@"SEL$1"), SCALE_ROWS=281.2054138)
OPTIMIZER_FEATURES_ENABLE(default)
Posted in 10gR1, 10gR2, 11gR1, Query Optimizer

EvoLve theme by Theme4Press  •  Powered by WordPress Striving for Optimal Performance