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
 is there any difference performance wise

Author  Topic 

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-12-04 : 00:26:30
Dear All,
is there any difference performance wise using
select * from my_table
and
select mycol1,mycol2....mycoln from my_table


actually i've read from one article the there is big difference....
please clear my doubt...
thanks in advance

Vinod
Even you learn 1%, Learn it with 100% confidence.

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-12-04 : 00:44:53
quote:
Originally posted by sunsanvin

Dear All,
is there any difference performance wise using
select * from my_table
and
select mycol1,mycol2....mycoln from my_table


actually i've read from one article the there is big difference....
please clear my doubt...
thanks in advance

Vinod
Even you learn 1%, Learn it with 100% confidence.



Unless you are querying every column in the table, there will be performance difference between the two queries. The articles you read would have explained why/where the difference lies...

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-12-04 : 01:15:41
quote:
Originally posted by dinakar

Unless you are querying every column in the table, there will be performance difference between the two queries. The articles you read would have explained why/where the difference lies...



so using column names is better than using * ????????
can you please give me some explanation

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-12-04 : 07:15:31
"actually i've read from one article the there is big difference...."
Re-read the article.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-12-04 : 07:19:06
Let me ask you another question:

Suppose you are going to market to purchase some fruits. You carry a single bag. Now tell me what is the difference if you buy 1 dozen of apples or if you buy 5 dozen of apples?

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2007-12-04 : 11:37:47
If you are selecting every column then there is no real difference. However, if you do not need every column then you should not return every column. The real issue is that "SELECT *" is just bad form for production code.
Go to Top of Page

sunsanvin
Master Smack Fu Yak Hacker

1274 Posts

Posted - 2007-12-05 : 00:18:02
Thank you Experts...........
i got the clarity.......

and regarding the article....it is almost two years back i read the article.....that is why i dont exactly know how i found that one....

any way i'm using all the columns in every statement...so i'm continuing with *.


thanks a lot GURUs

Vinod
Even you learn 1%, Learn it with 100% confidence.
Go to Top of Page

jezemine
Master Smack Fu Yak Hacker

2886 Posts

Posted - 2007-12-05 : 02:01:58
please don't continue with select *

there are more drawbacks to it besides fetching too much data. if someone adds a column, your code is broken.

other reasons here (as well as some cases when it's appropriate)
http://weblogs.sqlteam.com/brettk/archive/2004/04/22/1272.aspx


elsasoft.org
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-12-05 : 02:24:36
Some poeple would say "I use select * from table where 1=0" to know the structure of table

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -