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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 simple queries VS complex query?

Author  Topic 

debradeng
Starting Member

46 Posts

Posted - 2006-12-12 : 16:58:04
I need retrieve data from certain tables.There are two options:1 use one complex query with many table joined together to get all information;or 2 use several simple queries get data from different tables.

From performance and cost view,which way is better and why?

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2006-12-12 : 17:02:05
The one that runs the fastest is better.





CODO ERGO SUM
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-12 : 17:12:29
Dear Michael,the reason that I can not decide which is better is because I don't know how to find out which runs faster.Do you have any suggestion?

Thank you!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-12 : 17:15:48
Timing them?


Peter Larsson
Helsingborg, Sweden
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-12 : 17:21:12
to Peso,I am using MS SQL 2005.Is there any tools that I can use or you mean "Timing them" manually?

Thank you!
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2006-12-12 : 17:25:44
A simple timing device can be this.

Put this BEFORE your code

declare @dt datetime

DBCC DROPCLEANBUFFERS
DBCC FREEPROCCACHE

select @dt = getdate()


<do your thing here>

And put this after your code

select datediff(ms, @dt, getdate()) as Milliseconds



Peter Larsson
Helsingborg, Sweden
Go to Top of Page

debradeng
Starting Member

46 Posts

Posted - 2006-12-12 : 17:52:22
To Peso,
I tried the above method,but ...
"User 'MyDB'does not have permission to run DBCC DROPCLEANBUFFERS.User 'MyDB' does not have permission to run DBCC freeproccache."

I still got the Milliseconds value,I am not sure if it accounts.About the timing device,I have no idea before.Would you like give me some advice,eg. from where I can find more this kind skills etc.

Thank you very much!
Go to Top of Page
   

- Advertisement -