Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / New Users / July 2006

Tip: Looking for answers? Try searching our database.

DB Performance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
krishjaya - 26 Jul 2006 15:36 GMT
I have to use large volume SQL DB.

My Table name is 'Customer' and has 52 fields with heavy data.

Which SQL command is more fast? & why?

1.   SELECT   COUNT (*)  FROM Customer   WHERE CustId =
'1212322321313';
2.   SELECT   COUNT ( CustId )  FROM  Customer  WHERE  CustId =
'1212322321313';

Thanx
Kevin Spencer - 26 Jul 2006 15:57 GMT
Number 2 is faster. For number 1, the database needs to query for the
columns. For number 2, the columns are already specified.

Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Salad Alchemist

Sequence, Selection, Iteration.

>I have to use large volume SQL DB.
>
[quoted text clipped - 8 lines]
>
> Thanx
sloan - 26 Jul 2006 16:29 GMT
If CustID is not nullable, then you'll get the same results.

However, I think you'll get different behavior if you have a nullable
column.. and you specify it.

Test it to make sure.

declare @t table (EmpID int not null  , DOB datetime null )
set nocount on
insert into @t (EmpID , DOB) values ( 123 , GETDATE() )
insert into @t (EmpID) values (456 )
set nocount off

SELECT   COUNT ( *)  FROM  @t
select count(dob) from @t

Just throwing it out there  .......  as a small gotcha.

> I have to use large volume SQL DB.
>
[quoted text clipped - 8 lines]
>
> Thanx
Michael Nemtsev - 26 Jul 2006 17:51 GMT
Hello krishjaya,

You can use SQL Clients such as Management Studio, EMS or smth else to see
Exec plan of your query.
A lot of SQL clients can analyzy sql query and show you the execution plan
of your queries and time on each state of execution.

k> I have to use large volume SQL DB.
k>
k> My Table name is 'Customer' and has 52 fields with heavy data.
k>
k> Which SQL command is more fast? & why?
k>
k> 1.   SELECT   COUNT (*)  FROM Customer   WHERE CustId =
k> '1212322321313';
k> 2.   SELECT   COUNT ( CustId )  FROM  Customer  WHERE  CustId =
k> '1212322321313';
k> Thanx
k>
---
WBR,
Michael  Nemtsev :: blog: http://spaces.msn.com/laflour

"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
krishjaya - 27 Jul 2006 08:04 GMT
Ok Thanx for comments

Then can u explain me what is deference between

SELECT   COUNT ( * )  FROM Customer
SELECT   COUNT ( 0 )  FROM Customer

Thnx

KJ

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.