SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 SQL Select query performance
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

yomi
Starting Member

India
25 Posts

Posted - 02/01/2013 :  05:09:00  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/01/2013 :  06:33:55  Show Profile  Reply with Quote
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

India
25 Posts

Posted - 02/01/2013 :  06:41:37  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/01/2013 :  06:50:02  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 02/01/2013 :  08:43:13  Show Profile  Reply with Quote
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

India
52317 Posts

Posted - 02/01/2013 :  12:23:50  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000