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
 SQL Select query performance

Author  Topic 

yomi
Starting Member

25 Posts

Posted - 2013-02-01 : 05:09:00
I have two query's
select * from tableName

AND

Select col1,col2 from tableName

Which One is faster and why?






Yogesh

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-01 : 06:33:55
depends on factors like presence of indexes, total columns in table etc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

yomi
Starting Member

25 Posts

Posted - 2013-02-01 : 06:41:37
Hi visakh16,

how it is depends on number of columns in table and why i want small brief answer.

Yogesh
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-01 : 06:50:02
it will see if it can read columns from index easily over traversing whole table, based on that optimizer might decide to use the index table or read from the actual table. If its small dataset, it will go for table scan (or clustered index scan if present) in most cases.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2013-02-01 : 08:43:13
Visakh, can you answer homework question #5 also? Thanks.








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-01 : 12:23:50
quote:
Originally posted by DonAtWork

Visakh, can you answer homework question #5 also? Thanks.








How to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx




Sure
at least it was more of conceptual one

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -