Query Plan Execution Order

  • tommyh (10/27/2011)


    Yes the stream aggregate gets called first... but it hasnt finished. So is the important part which gets called first or which gets finished first? Personally i think its the part that gets finished first thats important (or more precisly the thing that performs its purpose first). I cant say a function has been executed when it hasnt actually done anything.

    Got it wrong because I just parroted something I picked up from this site. Moving a little fast this morning.

    However, while I have no quibble with the explanation, I think I prefer Tommy's point of view semantically. I tend to think of "Execute" in terms of completion. The example that came to mind was a recursive call. Although the first call starts "executing" first, it can't complete its business until all subsequent calls have completed.

    Thanks to SQL Kiwi for the question.

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

  • Hugo Kornelis (10/27/2011)


    "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.

    Excellent explanation Hugo 🙂

    Oh, and I got the question wrong. 😛

  • tommyh (10/27/2011)


    Yes the stream aggregate gets called first... but it hasnt finished. So is the important part which gets called first or which gets finished first? Personally i think its the part that gets finished first thats important (or more precisly the thing that performs its purpose first). I cant say a function has been executed when it hasnt actually done anything.

    Could be a language thing though that i put a different meaning into "executes" then everyone else 🙂

    /T

    I agree with tommy on this one. The question is a bit flawed. If you are attempting to teach the reader that the plan started with the left-most operation, then ask that in the question. Otherwise, you are attempting to bait the reader (unintentionally of course) into choosing the meaning of 'executes first'.

    Nonetheless, the links are great ones to read and understand.

  • ksummerlin-532910 (10/27/2011)


    tommyh (10/27/2011)


    Yes the stream aggregate gets called first... but it hasnt finished. So is the important part which gets called first or which gets finished first? Personally i think its the part that gets finished first thats important (or more precisly the thing that performs its purpose first). I cant say a function has been executed when it hasnt actually done anything.

    Could be a language thing though that i put a different meaning into "executes" then everyone else 🙂

    /T

    I agree with tommy on this one. The question is a bit flawed. If you are attempting to teach the reader that the plan started with the left-most operation, then ask that in the question. Otherwise, you are attempting to bait the reader (unintentionally of course) into choosing the meaning of 'executes first'.

    Nonetheless, the links are great ones to read and understand.

    Although I got it wrong, I disagree with you.

    In this code, what executes first?

    function main(){

    return sayHello() + " " + sayWorld()

    }

    function sayHello(){

    return "Hello"

    }

    function sayWorld(){

    return "World"

    }

    I think it's not hard at all to identify the function that executes first in this pseudo-code fragment.

    I'm sure that Paul wants us to get away with this concept.

    -- Gianluca Sartori

  • Tough question. Good learning opportunity. Thanks Paul.

  • Great question and explanation. I answered a little too quickly.

  • Good question.

    I got it wrong, of course. 😀 But no complaints, other than about the mistreatment of English grammar (iterators don't execute).

    Probably because I answered the wrong the question. :w00t: Perhaps Kiwi English is different from Teuchtar English :hehe:;-)

    I answered "which is executed first", not "which executes first", because I took "executes" to be an example of the barbarous practise advocated by the Plain English fundamentalist idiots of refusing to employ the passive :angry: (after all, none of the iterators executes, only the computer does that) and I take "is executed" to mean "execution is completed" not "execution is started" because I think it's far more common for a past participle in English to imply completed action than commencement of action (except when the verb describes an inherently ongoing process or the perfective aspect is cancelled by use of a progressive tense in an auxiliary verb).

    But here "it executes" is clearly being used to mean "its execution commences". Pehaps that is yet another language shift promoted by the barbarian Plain English Police? It's not a usage I've ever noticed before, but it's certainly barbarous enough to be something advocated by the PEP mob.

    PND(Bill) Patterson made this passing comment about the PEP and passives on the OldIrish list last month: 'A curious feature of the passive in English is that the 'Plain English' police are trying to root it out with a zeal which suggests that it is seen as morally reprehensible, perhaps a failure of positive thinking and active vigour, if not worse. Hence, perhaps, we have the tendency, especially in American English, to use indicatives in what is clearly a passive sense, causing imprecision and possible ambiguity: e.g. "The new version of MS Windows ships tomorrow"'.

    Anyway, it was a good question; but 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).

    Tom

  • Nice question. Definitely learned something today.

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


    ... because I think it's far more common for a past participle in English to imply completed action than commencement of action ...

    I couldn't have said it better. Thanks Tom!

    [font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
    Connect to me on LinkedIn

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

  • Cool/Cruel question:-D

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • 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.

    -- Gianluca Sartori

  • 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.

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I'm with those who took "which executes first" to mean "which completes its execution first" rather than "which starts its execution first".

    But I suspect I'd have got it wrong even if I'd made the correct interpretation 🙂

  • 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.

    Damn, I'm reading that book but it seems that I didn't get to that chapter yet.

    I obviously got it wrong but learned something amazing. :w00t:

    That's one of those days that makes me think that a visit to SSC is all I need to become a better professional.

    Thank you, Paul, for the references and Hugo for the explanation.

    Best regards,

    Best regards,

    Andre Guerreiro Neto

    Database Analyst
    http://www.softplan.com.br
    MCITPx1/MCTSx2/MCSE/MCSA

Viewing 15 posts - 16 through 30 (of 103 total)

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