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 «««1234

Table Access Order Expand / Collapse
Author
Message
Posted Saturday, September 24, 2011 8:38 AM


SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Thursday, June 26, 2014 5:34 AM
Points: 897, Visits: 1,486
SQL Kiwi (9/23/2011)Adam (Machanic) would no doubt want me to encourage you to share a link to SQLblog instead (traffic = advertising = pays the hosting bills) but I understand that is not always possible.


I'm currently starting a new SQL blog(it's very basic now and in Portugues) and I'll be adding links to your blog, Paul Randall's, Kimberly Tripp's, GilaMonster's and others if that's ok.

It's sad that some people will copy an article reinventing the wheel and stealing the credit instead of sending the reader to the right place and giving credits to those who are due.

I'm just a learner. :D

Best regards,


Best regards,

Andre Guerreiro Neto

Database Analyst
http://www.softplan.com.br
MCITPx1/MCTSx2
Post #1180511
Posted Saturday, September 24, 2011 9:01 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:32 PM
Points: 11,194, Visits: 11,112
codebyo (9/24/2011)
I'm currently starting a new SQL blog(it's very basic now and in Portugues)...

Looks good! I am also a fan of Fabiano Amorim by the way.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1180515
Posted Friday, September 30, 2011 4:17 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 5,018, Visits: 10,523
Great question, Paul!
I got it wrong, as usual.
I was highly tempted to pick the correct answer based on how the hash operator works, but I suspected there was a "trick" somewhere and I didn't listen to my brain.

Anyway, I have a doubt and I'm sure you can clear things up.

Here's a small test I ran:

SET STATISTICS IO ON

-- Changed to temp tables in order to recognize the table names
-- in STATISTICS IO output
CREATE TABLE #A (a INT NOT NULL)
CREATE TABLE #B (b INT NOT NULL)

SELECT COUNT_BIG(*)
FROM #A
LEFT HASH JOIN #B ON [#B].b = [#A].a

SELECT COUNT_BIG(*)
FROM #A
RIGHT HASH JOIN #B ON [#B].b = [#A].a

Output:

Warning: The join order has been enforced because a local join hint is used.

--------------------
0

(1 row(s) affected)

Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table '#A__000000024106'. Scan count 1, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Warning: The join order has been enforced because a local join hint is used.

--------------------
0

(1 row(s) affected)

Table 'Worktable'. Scan count 0, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table '#B__000000024107'. Scan count 1, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.
Table '#A__000000024106'. Scan count 1, logical reads 0, physical reads 0, read-ahead reads 0, lob logical reads 0, lob physical reads 0, lob read-ahead reads 0.


As you can see, in this case STATISTICS IO returns objects in reverse order. Is this sensible and/or guaranteed/documented?
I couldn't find anything on the subject.


--
Gianluca Sartori

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #1183639
Posted Friday, September 30, 2011 4:58 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 1:32 PM
Points: 11,194, Visits: 11,112
Gianluca Sartori (9/30/2011)
As you can see, in this case STATISTICS IO returns objects in reverse order. Is this sensible and/or guaranteed/documented? I couldn't find anything on the subject.

I don't know the answer to that; however I'm pretty sure it isn't documented or guaranteed.




Paul White
SQL Server MVP
SQLblog.com
@SQL_Kiwi
Post #1183656
Posted Saturday, October 1, 2011 2:53 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:42 AM
Points: 5,018, Visits: 10,523
SQL Kiwi (9/30/2011)
Gianluca Sartori (9/30/2011)
As you can see, in this case STATISTICS IO returns objects in reverse order. Is this sensible and/or guaranteed/documented? I couldn't find anything on the subject.

I don't know the answer to that; however I'm pretty sure it isn't documented or guaranteed.


Thank you, Paul.
I did a couple of tests and turns out that it was just a coincidence. Well, not entirely: the order of the tables in the STATISTICS IO output is often very similar to the execution order in the query plan, but it starts diverging when tables are accessed more than once, or parallelism kicks in, or... many other things.


--
Gianluca Sartori

Get your two-cent-answer quickly
spaghettidba.com
@spaghettidba
Post #1184032
« Prev Topic | Next Topic »

Add to briefcase «««1234

Permissions Expand / Collapse