home »forums »asp.net topics »data access »How to find the query is optimised or not?

How to find the query is optimised or not?

Topic RSS Feed

Posts under the topic: How to find the query is optimised or not?

Posted: 10/15/2009 2:44:39 PM

Contributor 2596 points Contributor
  • Joined on: 11/29/2008 6:26:22 AM
  • Posts: 53

Hi,
I have a table with name user,this table contains 5 columns.
Now I want to select all these 5 columns,there is two ways to do this

1. Select * From User
2. Select [ColumnName1],[ColumnName2]....[ColumnName5] From User

Both Query Gives me the same results.
Now my question is that in both the Queries which one is  optimised query,
and how we find out the optization of the queries


Posted: 10/15/2009 9:20:59 PM

Contributor 5349 points Contributor
  • Joined on: 4/15/2009 12:12:23 PM
  • Posts: 236
answered  Answered

I'm not a SQL expert but IMOH, If you are going to select certain columns in a Table then i would prefer Option 2. this would increase the performance of your query because you are only filtering the wanted columns in the table..

Here's a useful article that you can refer on : How To: Optimize SQL Queries


Posted: 2/18/2010 12:52:53 AM

Lurker 180 points Lurker
  • Joined on: 12/28/2009 4:13:31 AM
  • Posts: 8

Vijjendra said:

1. Select * From User
2. Select [ColumnName1],[ColumnName2]....[ColumnName5] From User

Both Query Gives me the same results.
Now my question is that in both the Queries which one is  optimised query,
and how we find out the optization of the queries

You can run the sql profiler to check which query takes more time to run...

please visit this

http://searchsqlserver.techtarget.com/tip/0,289483,sid87_gci1171978,00.html


Posted: 2/18/2010 1:46:02 AM

Contributor 2596 points Contributor
  • Joined on: 11/29/2008 6:26:22 AM
  • Posts: 53
answered  Answered

Thanks yrbyogi  and Vinz
I got my question's answer from the following link:
http://stackoverflow.com/questions/321299/what-is-the-reason-not-to-use-select


Posted: 2/22/2010 4:35:20 AM

Lurker 180 points Lurker
  • Joined on: 10/23/2009 2:43:08 AM
  • Posts: 14

dear sir i go through the link which you had mationed in ur answer bt i am still in confusion

will you please make yhe point clera

 


Page 1 of 1 (5 items)