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

Posts in category Query Optimizer

Ad: CBO Days 2012 – Final Agenda

Nov28
2012
3 Comments Written by Christian Antognini

The 11th and 12th of December and, therefore, the CBO Days in Zurich are approaching. Given the high quality of the speakers that accepted my invitation and the number of people that decided to attend the event, in my opinion it will be a blast! By the way, if you are interested in attending the event, do not wait any longer. In fact, from the 80 available seats, 75 are taken.

Here is a preview of the agenda:

Tuesday 11th December

  • 09:00 – 09:10: Welcome and Introduction, Christian Antognini
  • 09:10 – 10:30: The History of the Oracle Optimizer, Maria Colgan
  • 10:30 – 11:00: Coffee break
  • 11:00 – 12:20: Query Transformations, Joze Senegacnik
  • 12:20 – 13:50: Lunch
  • 13:50 – 15:10: New strategies for Statistics in 11g, Jonathan Lewis
  • 15:10 – 15:40: Coffee break
  • 15:40 – 17:00: Understanding Parallel Execution, Randolf Geist
  • 17:00 – 19:00: Let’s meet over drinks

Wednesday 12th December

  • 09:00 – 10:20: The Evolution of Histograms, Jonathan Lewis
  • 10:20 – 10:50: Coffee break
  • 10:50 – 11:20: The Oracle Optimizer: Behind The Curtain, Mohamed Zait
  • 11:20 – 12.10: The Oracle Optimizer: An Insider Perspective (Part 1), Mohamed Zait
  • 12:10 – 13:40: Lunch
  • 13:40 – 15:00: The Oracle Optimizer: An Insider Perspective (Part 2), Mohamed Zait
  • 15:00 – 15:30: Coffee break
  • 15:30 – 16:50: How the Query Optimizer Learns from Its Mistakes, Christian Antognini

For further information about the event click here.

Posted in Speaking, Trivadis

Ad: CBO Days 2012

Sep27
2012
Leave a Comment Written by Christian Antognini

The company I work for, Trivadis, is very pleased to organize, the 11th and 12th of December, an outstanding seminar with top guest speakers in Zurich. This year’s focus will be on the Oracle query optimizer, also known as a cost-based optimizer (CBO).

The query optimizer is not only one of the most complex pieces of software that constitutes the Oracle kernel; it is also one of the most unappreciated. Why? To make the best and most efficient use of the query optimizer, you definitely need to understand how it works. This is exactly what we are aiming for at the CBO Days.

Enjoy the two days with:
- Jonathan Lewis, JL Computer Consultancy (GB)
- Jože Senegačnik, DbProf (SI)
- Maria Colgan, Optimizer product manager, Oracle Corporation (USA)
- Mohamed Zait, Optimizer chief developer, Oracle Corporation (USA)
- Randolf Geist, Freelance (DE)
- Christian Antognini, Trivadis (CH)

For further information please click here.

EARL BIRD BOOKINGS: 15% discount if you enroll until November 1st. I look forward to meet you there!

Posted in Speaking, Trivadis

Index Scan with Filter Predicate Based on a Subquery

Feb06
2012
4 Comments Written by Christian Antognini

Most execution plans can be interpreted by following few basic rules (in TOP, Chapter 6, I provide such a list of rules). Nevertheless, there are some special cases. One of them is when an index scan, in addition to the access predicate, has a filter predicate applying a subquery.

The following execution plan, taken from Enterprise Manager 11.2, is an example (click on the image to increase its size):
Execution Plan
Notes:

  • According to the order column the first operation being executed is the scan of the I2 index. Unfortunately this is wrong. In fact the first operation being executed is the scan of the I1 index. This is a bug in Enterprise Manager. I wanted to show you this example to demonstrate that not only for us it might be difficult to correctly interpret an execution plan ;-)
  • The filter predicate IS NOT NULL is also wrong. This is not a bug, however. It is a limitation in the current implementation. The problem is that in some cases the V$SQL_PLAN and V$SQL_PLAN_STATISTICS_ALL views are not able to show all the necessary details.

Without seeing the query on which this execution plan is based, it is not obvious at all to know what’s going on. So, here is the query:

SELECT *
FROM t1
WHERE n1 = 8
AND n2 IN (SELECT t2.n1 FROM t2, t3 WHERE t2.id = t3.id AND t3.n1 = 8) 

Based on the query it is essential to point out that the access predicate "T2"."N1"=:B1 cannot be evaluated and, therefore, the scan of the I2 index cannot be carried out, without having a value passed through the B1 bind variable. In other words, without knowing the value of T1.N2.

To describe how this execution plan is carried out, let’s have a look to the information provided by the DBMS_XPLAN.DISPLAY function (which does not expose the limitation related to the filter predicate).

-----------------------------------------------
| Id  | Operation                      | Name |
-----------------------------------------------
|   0 | SELECT STATEMENT               |      |
|   1 |  TABLE ACCESS BY INDEX ROWID   | T1   |
|*  2 |   INDEX RANGE SCAN             | I1   |
|   3 |    NESTED LOOPS                |      |
|   4 |     TABLE ACCESS BY INDEX ROWID| T2   |
|*  5 |      INDEX RANGE SCAN          | I2   |
|*  6 |     TABLE ACCESS BY INDEX ROWID| T3   |
|*  7 |      INDEX RANGE SCAN          | I3   |
-----------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------
2 - access("N1"=8)
    filter( EXISTS (SELECT /*+ LEADING ("T2" "T3") USE_NL ("T3") INDEX
           ("T3" "I3") INDEX_RS_ASC ("T2" "I2") */ 0 FROM "T3" "T3","T2" "T2" WHERE
           "T2"."N1"=:B1 AND "T3"."N1"=8 AND "T2"."ID"="T3"."ID"))
5 - access("T2"."N1"=:B1)
6 - filter("T2"."ID"="T3"."ID")
7 - access("T3"."N1"=8)

The operations are carried out as follows:

  1. Operation 2 applies the access predicate "N1"=8 by scanning the I1 index.
  2. For each key returned by the previous scan, the subquery is executed once. Note that the subquery carries out a nested loop. While the outer loop accesses the T2 table, the inner loop accesses the T3 table.
  3. The first operation of the outer loop is operation 5. It applies the access predicate "T2"."N1"=:B1 by scanning the I2 index. Based on the rowid returned by the index access the T2 table is accessed (operation 4).
  4. For each row returned by the outer loop, the inner loop is executed once. The first operation of the inner loop is operation 7. It applies the access predicate "T3"."N1"=8 by scanning the I3 index. Based on the rowid returned by the index access the T3 table is accessed (operation 6) and the filter predicate "T2"."ID"="T3"."ID" (the join condition) is applied. By the way, it is interesting to notice that, contrary to the join condition is not applied as an access predicate, as it usually happens.
  5. If the subquery returns a row, the rowid returned by operation 2 can be used to access the T1 table (operation 1). The row extracted from this operation is sent to the caller.

All in all, this is a very special execution plan…

In summary, be careful when you see an index scan with a filter predicate applying a subquery. The execution plan might not be carried out as you expect at first sight. It is also essential to point out that in such a case the predicate information is essential to fully understand what’s going on.

Posted in 10gR2, 11gR1, 11gR2, Bug, TOP
← Older Entries

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