Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/cache.php on line 36

Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/query.php on line 21

Deprecated: Assigning the return value of new by reference is deprecated in /home/jjonahha/public_html/oracle-internals/blog/wp-includes/theme.php on line 540
ORACLE INTERNALS » Advanced Query Optimization Question

Mar 02 2009

Advanced Query Optimization Question

Published by jonah.harris at 7:05 am under General, Internals, Performance, SQL

Having now had a couple days to rest and reflect, I can definitively say that SEOUC was great.  I’m really glad I attended, was able to meet a lot of new people, and have some good discussions about problems people faced both technically and given the current economy.  I was also able to get some good insight into other types of Oracle environments and felt the conference was an overall success.

The conference ended with a closing session on the topic of Oracle Exadata Storage Server presented by Oracle Director of Product Management, Charles Garry.  While the slide deck was quite marketing-heavy, Charles did a good job entertaining everyone and answering questions.

After the session, I had a few discussions with people regarding the Exadata architecture and the method by which Oracle Database is able to distribute nodes of a query execution plan directly to the storage server for local processing.  For people who haven’t worked on query optimizers and executors, it seems that this is an area of technical confusion.  Regardless, Charles and I both rode the shuttle back to the airport, which gave me a chance to talk with him about Oracle from both a company and technology perspective.

Also, now that I’m home and have completed my second SEOUC presentation, The Life of a Query, I wanted to follow-up on my experience and ask you a question.

First, the description of The Life of a Query is as follows:

Have you ever wondered what happens when you execute a query?  In this session, we’ll take a walk through the Life of an Oracle Query from beginning to end.  Not only does this help you better understand the various steps in the execution of your query, but it will also give you a good appreciation for the architecture of the Oracle Database server and, in particular, of the query optimizer.  You will gain valuable information that will allow you to solve performance issues and write more efficient queries going forward.  Additionally, I will share some of my insights into the Oracle optimizer as we move through this discussion.  This discussion is also a great refresher for those of you familiar with Oracle concepts and architecture.

In short, this session takes a query and walks through all major components of the Oracle database starting from the client and going through connection, the entire Oracle Kernel stack, and back to the client.  After the session, I received quite a few positive comments from attendees.  Moreover, I found that people are extremely interested in how query optimization works.

While I covered the basics of parsing, query rewrite, and optimization, it seemed that including view/subquery merging, basic algebraic optimization, join permutation, join elimination, and partition elimination wasn’t enough.  Surprisingly, someone even asked to go into more depth on the mathematics behind query optimization; specifically the application of graph theory to plans and the way costing is performed using a graph.  This brings me to my question:

Would anyone be interested in a fairly advanced presentation/article on query optimization?

For comparison purposes, my meaning of fairly advanced is between the level of Jonathan Lewis’ Cost-Based Oracle Fundamentals and not-quite pure math.  If I decide to do it, I’m thinking of presenting it similar to Craig Shallahamer’s based-on-math-yet-practically-applied Forecasting Oracle Performance, describing the math and theory but visually demonstrating how it applies to actual queries.  Thoughts?

7 Responses to “Advanced Query Optimization Question”

  1. Mathew Butleron 02 Mar 2009 at 10:06 am

    Hi Jonah,

    Any plans to publish a link to your presentation? It sounds interesting.

    Best Regards,

    Mathew Butler

  2. jonah.harrison 02 Mar 2009 at 1:47 pm

    Hey Mathew,

    Yes, the Life of a Query/Life of an Oracle Query presentation will be up soon. I have two versions of it, one that I did awhile ago and another which I did the night before the presentation. I prefer the newest one, but it’s a bit ugly and needs to be cleaned up a little.

    -Jonah

  3. Kevinon 02 Mar 2009 at 10:01 pm

    “After the session, I had a few discussions with people regarding the Exadata architecture and the method by which Oracle Database is able to distribute nodes of a query execution plan directly to the storage server for local processing.”

    ..is this still a source of confusion?

  4. jonah.harrison 02 Mar 2009 at 10:30 pm

    Hey Kevin,

    Thanks for checking out my blog.

    To answer your question, for those I talked to, I’m pretty sure they got it. However, it does seem that the majority of people I talk to seem to think the database is chopping the SQL predicate text out of the query and sending it directly to the storage server.

    Personally, I think it’s just a case of people not understanding query optimization and execution plans below the level of EXPLAIN PLAN. Many people don’t realize that the QEP contains actual nodes and that those nodes could be rewritten (as performed by the MSQ and KKFS subsystems) or shipped elsewhere (such as in parallel execution and certain RAC cases).

    Of course, having never seen the source and having reviewed the Exadata architecture for no more than a day or so myself, I may be wrong. For all I know, Oracle may be generating some SQL-ish statement from the storage predicate nodes like it does for distributed queries, but I doubt it. Care to share more insight?

    -Jonah

  5. Kevinon 03 Mar 2009 at 1:44 am

    “Care to share more insight?”

    …uh, I have how many blog posts on exadata ? :-)

  6. jonah.harrison 03 Mar 2009 at 1:50 am

    Kevin,

    Agreed that you have an endless supply of detailed Exadata blog postings :) In fact, that was my initial source of information.

    I was just wondering on that particular aspect: does it just pass the QEP nodes to the storage server?

    -Jonah

  7. Charles Schultzon 23 Apr 2009 at 9:14 pm

    Jonah,

    I found this thread quite interesting. As some who is hoping to learn more about internals, I would also love to see your “Life of a Query” presentation - particularly, to see to what level of detail you go to. =)

    You also mentioned a Shallahamer-like paper. I would love to see something like that as well. I love when theory collides with reality and we mere humans get something we can sink our teeth into.

    Thanks for your contributions,

Trackback URI | Comments RSS

Leave a Reply