Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 efficiency

Author  Topic 

KazaX
Starting Member

28 Posts

Posted - 2008-11-12 : 17:36:57
Hi folks!
have idea?
How can one estimate i/o required for a naive join and a block nested loop join if we have as follows

select r.a, s.c
from r,s
where r.b=s.b


r has 10^6 records and occupies 100mb
s has 10^5 " " 200mb
and cache holds 2 blocks
and blocks read from disk 50kb
and which outer loop - on R or S - is most efficient?
cheers

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-12 : 18:56:15
Just view the execution plan and the statistics to determine the costs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2008-11-13 : 05:12:21
And stop using that syntax. It won't keep working forever!

Do,

select
r.a
, s.c
from
r
INNER JOIN s ON s.b = r.b

Instead.




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page

KazaX
Starting Member

28 Posts

Posted - 2008-11-14 : 14:01:29
quote:
Originally posted by Transact Charlie

And stop using that syntax. It won't keep working forever!

Do,

select
r.a
, s.c
from
r
INNER JOIN s ON s.b = r.b

Instead.




Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION





thats good but writing that all staff, "inner join ON s.b" .... just "=" saves u time and effort :)
Go to Top of Page

KazaX
Starting Member

28 Posts

Posted - 2008-11-14 : 14:08:21
quote:
Originally posted by tkizer

Just view the execution plan and the statistics to determine the costs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog




Yeah, that s an idea :) but not effective. You got to be PROACTIVE. MAYBE execution will take up forever, what a gonna da :) ? If you know beforehand that execution never ends why to run it ?! As an expert how can one evaluate with figures that he has as knowledge beforehand and estimate i/o required, like # of records, cache etc. There must be a way. Knowledge is power, can anyone bear original ideas?

Go to Top of Page

lionofdezert
Aged Yak Warrior

885 Posts

Posted - 2008-11-14 : 14:08:44
No Kasa, charlie is right, that the ANSI Standard Joining Query, and one thing more that though "=" saves ur time while righting code but every time this query will run, Sql Server have to interpret it and placing INNER JOIN against your "=" sign, So Charlie Query is ANSI standard and Fast too.
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2008-11-14 : 14:13:13
There is an estimated query plan in management studio that can give you some information about a query based on the server statistics.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-11-14 : 15:01:56
quote:
Originally posted by KazaX

quote:
Originally posted by tkizer

Just view the execution plan and the statistics to determine the costs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog




Yeah, that s an idea :) but not effective. You got to be PROACTIVE. MAYBE execution will take up forever, what a gonna da :) ? If you know beforehand that execution never ends why to run it ?! As an expert how can one evaluate with figures that he has as knowledge beforehand and estimate i/o required, like # of records, cache etc. There must be a way. Knowledge is power, can anyone bear original ideas?





I can't figure out what you are asking.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

KazaX
Starting Member

28 Posts

Posted - 2008-11-17 : 05:52:10
quote:
Originally posted by tkizer

quote:
Originally posted by KazaX

quote:
Originally posted by tkizer

Just view the execution plan and the statistics to determine the costs.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog




Yeah, that s an idea :) but not effective. You got to be PROACTIVE. MAYBE execution will take up forever, what a gonna da :) ? If you know beforehand that execution never ends why to run it ?! As an expert how can one evaluate with figures that he has as knowledge beforehand and estimate i/o required, like # of records, cache etc. There must be a way. Knowledge is power, can anyone bear original ideas?





I can't figure out what you are asking.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog





Hello, there
Thx 4 reply..
The thing is I do not have million records in none of tables test and see the costs. I am wondering how Do I estimate if I am asked given that information? That is all.
Cheers
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-11-17 : 06:23:33
Insert millions of dummy records to see which plan you get.



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page
   

- Advertisement -