Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««7891011»»

Query Plan Execution Order Expand / Collapse
Author
Message
Posted Sunday, January 15, 2012 10:33 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:36 AM
Points: 11,192, Visits: 11,091
Sergiy (1/15/2012)
Both fuel counter and row counter are reset before the counted substance is being delivered.
Just proves the analogy is correct.

So the fuel counter executes first, cool. The analogy isn't a false analogy; just not a useful one (in my opinion).

If a fact does not fit your theory ditch the fact.

It's not a theory, it's published fact.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236382
Posted Sunday, January 15, 2012 10:37 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:36 AM
Points: 11,192, Visits: 11,091
Sergiy (1/15/2012)
How happy are those people about this one: Cursor loop executes before the first row of the cursor is fetched? Or Main routine executes before any of its subroutines?

You would have to ask them, but it does seem obvious that subroutines are called by a parent routine, and that cursors are declared and initialized before any data is fetched through them.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236383
Posted Sunday, January 15, 2012 11:46 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, July 20, 2014 5:23 PM
Points: 4,576, Visits: 8,341
SQL Kiwi (1/15/2012)

So the fuel counter executes first, cool. [/qoute]
Which means - Fuel counting executes before fuel is pumped.
Did you try it on real life people?


[quote]It's not a theory, it's published fact.

"Published" does not mean "fact".

The "fact" about the Sun circling around the Earth was published so many times during so many centuries by such big authorities that people got executed for defying that "fact".
I hope not to be executed for defying the "fact" published by big MVP's.

Post #1236397
Posted Sunday, January 15, 2012 11:49 PM
SSCarpal Tunnel

SSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal TunnelSSCarpal Tunnel

Group: General Forum Members
Last Login: Sunday, July 20, 2014 5:23 PM
Points: 4,576, Visits: 8,341
Fun part:

Question:
Which query plan operator executes first?

Correct answer:
The Stream Aggregate

My question:
Sorry, the Stream Aggregate executes what?
Post #1236398
Posted Monday, January 16, 2012 12:17 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:02 PM
Points: 5,916, Visits: 8,167
Hi Paul and Sergiy,

Can you please drop this? You are now both reiterating the same point again and again.

Sergiy has made his point that he disagrees with the answer (and even with the question, it seems). We all understand that.
It's also pretty obvious by now that Sergiy is not able to convince Paul (or any others who responded, including me) to see things his way. And that all who responded (mainly Paul at this time) are equally unable to convince Sergiy to see things our way.

I think continuing to argue is just a waste of everyone's time and energy - so I propose that we all just agree to disagree on this one, and move on.
Agreed?



Hugo Kornelis, SQL Server MVP
Visit my SQL Server blog: http://sqlblog.com/blogs/hugo_kornelis
Post #1236408
Posted Monday, January 16, 2012 12:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:36 AM
Points: 11,192, Visits: 11,091
Sergiy (1/15/2012)
Which means - Fuel counting executes before fuel is pumped.

The part that resets the counter does, yes. Of course, the total amount of fuel pumped is only shown once dispensing of fuel is complete. The analogy is not perfect because the mechanics of query plan execution and fuel dispensing are not that close. The fuel system has a direct feedback to shut off fuel delivery when the operator releases the nozzle grip, or when a pre-set volume or cost of fuel has been delivered. Fuel delivery would also stop, I guess, if the underground tank ran dry, but that is not the usual situation.

The analogy might work a little better in a simple SELECT COUNT(*) FROM Table plan, or perhaps one with a subquery with a TOP operator, but that is stretching things a bit. It's hard to see where the JOIN appears in fuel delivery for example. In any case, it all comes back to how the reader interprets 'executes'. Your view differs from the majority, which doesn't make it wrong, but many of your statements about other things have been. Your recent posts suggest that some of the learning points from this QotD have stated to sink in, which is the whole point.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236410
Posted Monday, January 16, 2012 12:26 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:36 AM
Points: 11,192, Visits: 11,091
Sergiy (1/15/2012)
Fun part: Question: Which query plan operator executes first? Correct answer: The Stream Aggregate

Thank goodness!

My question: Sorry, the Stream Aggregate executes what?

First!




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236413
Posted Monday, January 16, 2012 12:46 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 1:36 AM
Points: 11,192, Visits: 11,091
Hugo Kornelis (1/16/2012)
Hi Paul and Sergiy,

Can you please drop this? You are now both reiterating the same point again and again.

Sergiy has made his point that he disagrees with the answer (and even with the question, it seems). We all understand that.
It's also pretty obvious by now that Sergiy is not able to convince Paul (or any others who responded, including me) to see things his way. And that all who responded (mainly Paul at this time) are equally unable to convince Sergiy to see things our way.

I think continuing to argue is just a waste of everyone's time and energy - so I propose that we all just agree to disagree on this one, and move on.
Agreed?

Hi Hugo,

If Sergiy were simply trolling I would agree; but for me, the discussion still has value: Sergiy has picked up a few key concepts and learned that correlated seeks don't happen before the driving scan, for example. I fully don't expect him (or her) to ever fully accept that the question and answer are perfect (they're not!) but so long as even small progress is being made, I don't see it as a waste of my time.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1236416
Posted Monday, January 16, 2012 2:31 AM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 3:10 AM
Points: 1,712, Visits: 6,241
Sergiy (1/12/2012)
Hugo Kornelis (1/12/2012)
I think the problem is lingual.

"Is executed" can have two meanings.
1. Present tense, passive form - the code is invoked. Can be compared to running "EXEC MyStoredProc" in SQL Server. As soon as you run that command, execution passes to the first statement of your stored procedure - your stored procedure "is executed".
2. Present tense with perfect aspect - execution has finished. When the execution of your stored procedure has finished and control is returned to the caller, the stored procedure "is executed" (though I think most English speakers would use "has executed" here).

Paul's intention, and my interpretation, is the first meaning: execution starts. And with that meaning, Stream Aggregate is the correct answer, This is the first operator that gets control, initializes itself, then passes control to (by calling) the next operator.

Another way to explain this is to remember that operators do not "push" rows up to their parent operator; operators "pull" rows from their descendants. (Or, as Rob Farley worded it, "execution plans suck").


I don't think it's lingual.


An awful lot of bandwidth would have been saved if you'd just said "yes I agree, it's lingual"!


Post #1236453
Posted Monday, January 16, 2012 11:29 AM


SSCrazy Eights

SSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy EightsSSCrazy Eights

Group: General Forum Members
Last Login: 2 days ago @ 10:00 AM
Points: 8,551, Visits: 9,043
SQL Kiwi (1/15/2012)
Sergiy (1/15/2012)
How happy are those people about this one: Cursor loop executes before the first row of the cursor is fetched? Or Main routine executes before any of its subroutines?

You would have to ask them, but it does seem obvious that subroutines are called by a parent routine, and that cursors are declared and initialized before any data is fetched through them.

Actually, it is a real pain to use a cursor in such a way that the loop processing rows is entered before the first fetch is executed. I imagine that's what Sergiy is referring to as a "cursor loop", and that he's pointing out that the first fetch is executed before that loop is entered. But I can't see any connection at all between that and this QotD.

Aynway, to answer Sergiy's happiness question (I probably shouldn't answer it, but as he's specifically asked I think I have a little license here): I'm happy because the QotD and it's answer are perfectly correct (well, nothings perfect - but as near as we get), but thoroughly unhappy because Sergiy seems to be trying to turn the discussion into a debate on the meaning of the verb "execute" which has been interpreted with total accuracy by Paul and can never (in the English I hear, speak, read, and write) be interpreted as meaning "finishes its execution" as S appears to want it to be, and bringing up completely irrelevant and pointless analogies. Perhaps he could start a new thread on the meaning of "execute" (which we could all ignore)? Maybe I'm being unfair, but I can't see any point to the continuing discussion.


Tom
Post #1236766
« Prev Topic | Next Topic »

Add to briefcase «««7891011»»

Permissions Expand / Collapse