Oracle Performance Visualization videos from Sydney

Alex Gorbachev invited me to speak at Oracle Meetup @ Sydney event in April.

I in addition to useful (and less cool) stuff I showed some useful (and very cool) stuff there too. I demoed my PerfSheet tool and also something completely new what I’ve been working on for last few months. Alex has uploaded couple of videos in to youtube, if you’re interested what I’ve been up to in last few months, check them out here:

http://www.pythian.com/news/2590/sydney-oracle-meetup-2-visualizing-oracle-performance

Scripts for showing execution plans via plain SQL and also in Oracle 9i

Hi all,

Here are few scripts which allow you to query SQL execution plans and their execution statistics out from V$SQL_PLAN and V$SQL_PLAN_STATISTICS yourself.

Why would you want to do this as there’s the DBMS_XPLAN.DISPLAY_CURSOR() function in Oracle 10g?

Well, my scripts work also on Oracle 9.2. Also they give you better detail (and flexibility) compared to DBMS_XPLAN.DISPLAY_CURSOR.

Of course in 9i there’s the DBMS_XPLAN.DISPLAY function which you can use in conjuction with EXPLAIN PLAN FOR command, but that approach has problems. EXPLAIN PLAN treats all bind variables as varchar2 datatype, possibly causing the reported execution plan to be different from reality. Also, if you have a long running report from last night and you run explain plan today morning, then if optimizer statistics have changed meanwhile, the explain plan command might come up with a different execution plan again, which is different from reality.

So that’s why in 10g we have the DBMS_XPLAN.DISPLAY_CURSOR which goes directly to required library cache child cursor and extracts (unparses) the execution plan from there. The function uses V$SQL_PLAN% views as its data source. And guess what – these views are there in version 9.2 already! And thats’ where my scripts come in:

Here’s an example. Let’s set statistics_level=all so we get rowsource level execution stats for the cursor (note that this parameter makes your query consume much more CPU so it should only be used at session level for troubleshooting a specific performance issue):

SQL> alter session set statistics_level = all;

Session altered.

SQL> select count(*) from all_users;

  COUNT(*)
----------
        36

I know the hash value of this query, so lets report its execution plan, directly from library cache. This is the REAL execution plan inside that child cursor, not some estimate like EXPLAIN PLAN command gives:

[Read more...]

“Free” DBA_HIST AWR views in 11g…

I just noticed this in 11g Licensing doc ( http://download.oracle.com/docs/cd/B28359_01/license.111/b28287/options.htm#sthref69 ):

  • All data dictionary views beginning with the prefix DBA_HIST_ are part of this pack, along with their underlying tables.The only exception are the views: DBA_HIST_SNAPSHOT, DBA_HIST_DATABASE_INSTANCE, DBA_HIST_SNAP_ERROR, DBA_HIST_SEG_STAT, DBA_HIST_SEG_STAT_OBJ, and DBA_HIST_UNDOSTAT. They can be used without the Diagnostic Pack license.

This exception is not present in 10.2 license guide, so before 11g you can query V$SEGMENT_STATISTICS and V$UNDOSTAT’s history “for free” :)

Of course, collecting this data manually with a 1-line PL/SQL loop script isn’t hard either :)

I have been troubleshooting since I was a kid! :)

People often ask how come I know so much about Oracle (and some Unix) internals and how do I have such a passion for such things.
Also, another thing which you can notice is that for some reason a large amount of hardcore computer hackers, low level troubleshooters and various internals experts happen to come from Russia.

And I can answer why this is so :)

A little bit of history: I was born in Estonia and lived over 20 of my first years there. From 1940 to 1991 Estonia was occupied by Soviet Union (excluding few years during World War II when we were occupied by German forces).

So, as I was born in the end of seventies, most of my childhood we were still part of Soviet Union. And that applies to all russians and other nationalities in that empire too.

  • …This meant that all we could buy was Soviet Union products.
  • …And all these products usually had quality issues.
  • …Which meant that whenever I got some toy as present for christmas or my birthday – I first had to FIX it and only then I could play with it! :)
  • …That usually applied to toy cars, constructors and whatever non-trivial pieces of toys. Some things needed minor tweaking, some required complete disassembly and reassembly (sometimes you needed to improvise and come up with the missing pieces yourself :)
  • …Later on it also applied to bikes etc. The bike could be working in principle but you still needed to tune it to get it running smoothly (and to make sure that it wouldn’t break when you went downhill the max speed you could get).

So, there’s always something good in everything bad – I had to learn troubleshooting since I was a little kid! ;)