Query Plan Execution Order

  • L' Eomot Inversé (10/27/2011)


    it would have been even better if instead of "executes" it had said "is invoked" or "is called" or something similar, since "executes" leaves us guessing as to the meaning (as I said, it's the computer not the iterator that executes).

    Quite agree - it was the wording that tricked so many people... a shame as it was a good question 😉

  • SQLRNNR (10/27/2011)


    Gianluca Sartori (10/27/2011)


    LadyRuna (10/27/2011)


    I got it right, but only because I've read Grant Fritchey's book about execution plans. 🙂

    Ouch! I read that book as well.

    I'm totally hopeless.

    Ha - I was trying to remember where I had learned that. Maybe it was Grants book.

    I think that all people who answered correctly should pool their money and buy Grant a really decent bottle.

  • Gianluca Sartori (10/27/2011)


    LadyRuna (10/27/2011)


    I got it right, but only because I've read Grant Fritchey's book about execution plans. 🙂

    Ouch! I read that book as well.

    I'm totally hopeless.

    I also read that book...and still missed this one. Better go back and re-read.

    Great question.

    Rob Schripsema
    Propack, Inc.

  • Michael Lysons (10/27/2011)


    And, more importantly, congrats on winning the Webb Ellis, SQL Kiwi!

    Still celebrating here!

  • Another great question Paul with very interesting lesson behind it. Cheers mate!

  • Hugo Kornelis (10/27/2011)


    Good question, Paul!

    I had the correct answer,but only thanks to the fact that I attended SQL Saturday in Portland a few weeks back (just before the PASS Summit). I don't recall who said it, probably either Buck or Rob, but the quote itself will always stick: "Exection plans suck". Refering to the little-known fact that data is not pushed from right to left (as most people usually read plans, myself included), but pulled ("sucked") by the top-left operator from the operator to the right and below it.

    It must have been Rob Farley - I remember he came up with that memorable way of expressing it last year sometime.

  • As with others, I certainly don't mind getting a question wrong when I learn from it. At least I have lots of company!! 😛

  • I'm going to have to be a dissenting voice, I agree with Paul as to the nature of 'executes first'. It's what starts the chain, and begins the process.

    Thanks for an excellent question Paul, though I was in utter shock at first. I need a sammich, a beer, and an hour or two with these references methinks.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

  • I answered anything because I know nothing about the execution plan but I wanted to see the answer and read the discussion now, so I tried something... and got no luck: my answer was wrong and I still don't understand... So, here I am, with my question: is it important to undersand if you are (well, trying to be) a developper on a very small database?

  • tilew-948340 (10/27/2011)


    I answered anything because I know nothing about the execution plan but I wanted to see the answer and read the discussion now, so I tried something... and got no luck: my answer was wrong and I still don't understand... So, here I am, with my question: is it important to undersand if you are (well, trying to be) a developper on a very small database?

    It is very important if you are trying to design a query optimiser, but not many people do that. It is somewhat important if you are trying to write queries that are efficient - because you need to have some idea of how they execute, and if you can't read and understand a query plan and see how it works that can be difficult. If you are working on an OLTP system that runs on a vastly oversized platform, so that query efficiency isn't of any interest, it's not the least bit important.

    So maybe the case for most people is that it is somewhat important. (For me it used to be extremely important, but in those days I was building a data engine.)

    Actually it's not something that's difficult. If you have any knowledge of lazy functional languages (like Hope+ or Haskell or LML) you will understand about demand driven execution, and that's pretty much what is going on here.

    Alternatively, think of it as a very simple programme paradigm: the thing that produces the result calls the things that provide it with data, and those things all call other things that give them the data they need to produce their results, and so on. Apart from the top level, nothing produces any data or does anything at all unless it is asked to by something at the level above.

    Tom

  • Fantastic question, thanks!

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • L' Eomot Inversé (10/27/2011)


    tilew-948340 (10/27/2011)


    ... is it important to undersand if you are (well, trying to be) a developper on a very small database?

    ... So maybe the case for most people is that it is somewhat important. (For me it used to be extremely important, but in those days I was building a data engine.)

    Alternatively, think of it as a very simple programme paradigm: the thing that produces the result calls the things that provide it with data, and those things all call other things that give them the data they need to produce their results, and so on. Apart from the top level, nothing produces any data or does anything at all unless it is asked to by something at the level above.

    I didn't even know how to get the execution plan so I did some reseach and find it (CTRL-L ! simple as that!). Writes many sample query and now I understand! Yéééé!

    Thanks for your answer :kiss:

  • Hugo Kornelis (10/27/2011)


    Good question, Paul!

    I had the correct answer,but only thanks to the fact that I attended SQL Saturday in Portland a few weeks back (just before the PASS Summit). I don't recall who said it, probably either Buck or Rob, but the quote itself will always stick: "Exection plans suck". Refering to the little-known fact that data is not pushed from right to left (as most people usually read plans, myself included), but pulled ("sucked") by the top-left operator from the operator to the right and below it.

    Indeed it was Rob Farley. I had the honor to be in the room with both of you when he said it.

    14090 SW TENNESSEE LN

  • gary.rumble (10/28/2011)


    Hugo Kornelis (10/27/2011)


    Good question, Paul!

    I had the correct answer,but only thanks to the fact that I attended SQL Saturday in Portland a few weeks back (just before the PASS Summit). I don't recall who said it, probably either Buck or Rob, but the quote itself will always stick: "Exection plans suck". Refering to the little-known fact that data is not pushed from right to left (as most people usually read plans, myself included), but pulled ("sucked") by the top-left operator from the operator to the right and below it.

    Indeed it was Rob Farley. I had the honor to be in the room with both of you when he said it.

    Thanks, Gary (and Paul).

    I'll try to remember this so I can attribute the quote properly if -no, make that when- I steal it again.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • Yeah - that's my line. I'm pleased it's helping people remember this important aspect of how to read execution plans.

    Rob Farley
    LobsterPot Solutions & Adelaide SQL Server User Group
    Company: http://www.lobsterpot.com.au
    Blog: http://blogs.lobsterpot.com.au

Viewing 15 posts - 31 through 45 (of 103 total)

You must be logged in to reply to this topic. Login to reply