Archive

Archive for April, 2009

Tracing Oracle SQL plan execution with DTrace

April 24th, 2009

SQL is a declarative language – in other words you just declare what needs to be done and Oracle takes care of the part how it’s done.

However there’s nothing declarative about the actual SQL execution when it happens. SQL plan is just a tree of kernel rowsource functions executed in a specific order (defined in child cursor’s sql area).

The root of SQL plan is where the fetch function (opifch2 for example) gets the rows for passing back to the user (or PL/SQL engine).
The branches are operations like joins, union etc, which don’t have access to any data themselves and can just call other functions recursively to get rows
The leaves are the execution plan operations without any children, they call data layer to acces actual datablocks.

The first execution plan line (with lowest ID) without any children is the one where data access starts, that’s the place where first logical IO happens.

A commented exec plan is below:

SQL> select count(*) from all_users;

  COUNT(*)
----------
        35

SQL> @x

PLAN_TABLE_OUTPUT
--------------------------------------------------------------------------------
SQL_ID  b2zqhgr5tzbpk, child number 0
-------------------------------------
select count(*) from all_users

Plan hash value: 3268326079

--------------------------------------------------------------------------
| Id  | Operation            | Name  | E-Rows |  OMem |  1Mem | Used-Mem |
--------------------------------------------------------------------------
|   1 |  SORT AGGREGATE      |       |      1 |       |       |          |       <- ROOT
|*  2 |   HASH JOIN          |       |     35 |  1517K|  1517K|  637K (0)| <- BRANCH
|*  3 |    HASH JOIN         |       |     35 |  1593K|  1593K| 1361K (0)| <- BRANCH
|   4 |     TABLE ACCESS FULL| TS$   |     13 |       |       |          |   <- LEAF
|*  5 |     TABLE ACCESS FULL| USER$ |     35 |       |       |          |    <- LEAF
|   6 |    TABLE ACCESS FULL | TS$   |     13 |       |       |          |    <- LEAF
--------------------------------------------------------------------------

Predicate Information (identified by operation id):
---------------------------------------------------

   2 - access("U"."TEMPTS#"="TTS"."TS#")
   3 - access("U"."DATATS#"="DTS"."TS#")
   5 - filter("U"."TYPE#"=1)

I have written about how to map execution plan lines back to kernel functions here:

http://blog.tanelpoder.com/2008/06/15/advanced-oracle-troubleshooting-guide-part-6-understanding-oracle-execution-plans-with-os_explain/

The above approach is based on pstack, mostly useful for demonstrations but has helped me to diagnose one spinning condition in an execution plan once (that’s the whole reason I came up with this technique).

As I said above, SQL execution just means that the kernel’s rowsource functions are executed in a loop with order and hierarchy specified in the child cursor’s execution plan.

So, if you want to learn and really understand the sequence of SQL plan execution – it’s dead easy with DTrace. Here’s what happens when you fetch from the above execution plan:

Read more…

  • Share/Bookmark

Tanel Poder Cool stuff, DTrace, Internals, Oracle, Troubleshooting

Seminar in Edinburgh next week – discount to UKOUG members (and a little comment about Snapper)

April 23rd, 2009

Just wanted to let you know that there are still places left for my troubleshooting seminar in Edinburgh next week and there’s a 20% discount for UKOUG members.

The event takes place 27-28 April – Check the PiSec seminar page if you’re interested!

Btw I will have whole 10 free days after the Edinburgh event so expect some interesting and useful blog entries then (instead of the marketing stuff what you’ve had to tolerate for last few times ;)

I have moved Snapper v2.01 (out of beta now) to http://www.tanelpoder.com/files/scripts/snapper.sql , it’s layout & output columns are configurable now btw (search for “config” in the script).
If anyone still misses the old version of snapper (v1.07), you can download it from here

  • Share/Bookmark

Tanel Poder Oracle, Training, Troubleshooting

Oracle buys Sun – hooray!

April 20th, 2009

More details here:

http://www.oracle.com/sun/index.html

Not that I care too much from the business aspect, but I sure hope this means that Solaris will become a viable OS to run Oracle on x64 platform!!! Btw the OS itself is already more than good enough – but it just should be properly supported by Oracle!

  • Share/Bookmark

Tanel Poder Cool stuff, Oracle

Seminar feedback and pictures from Singapore

April 20th, 2009

I’ve been busy with a series of seminars, so haven’t managed to blog much…

Karl Arao has posted some feedback from my Singapore seminar and also the pictures we took with attendees. By the way, he has other good Oracle stuff in his blog so check it out here.

  • Share/Bookmark

Tanel Poder Oracle, Training

Done with my seminar in Netherlands – here’s some feedback and couple beta new versions of my scripts

April 5th, 2009

The Miracle Masterclass I delivered last week in Netherlands was awesome, I had lots of attendees and lots of good questions and feedback. As usual, I ran out of time in the end though. I will make this up with some articles about the stuff I didn’t have time to explain :)

I used Snapper v2.0 beta during my demos there and also an improved version of LatchProfX which can give some additional context information about reasons why latches were taken. As they are beta, not final versions, I have uploaded them into a temporary location:

Update: These scripts are out of beta now so here are their permanent locations:

Also, the Sesspack (session level statspack) v0.05 files are in my TPT script set, under tools/sesspack_v0.05 directory in the zip file:

Toine van Beckhoven attended the seminar as well and wrote a review of it, if you’re still hesitating if you should attend as well, read his review first :)

  • Share/Bookmark

Tanel Poder Cool stuff, Oracle, Performance, Training, Troubleshooting