Asterisk In Select Query

I have a query that does something like the following:

SELECT d.*, a.* FROM TABLE1 d, TABLE2 a WHERE ......

Is there a degradation in performance or are the indexes ignored by using the d.* and a.* instead of the actual column names like d.COLUMN1, d.COLUMN2, a.COLUMN1, a.COLUMN2?  Thanks.

BTW, I am using SQL Server 2000, 2005 and Oracle 9 and 10.
pcarrollnfAsked:
Who is Participating?
 
Guy Hengel [angelIII / a3]Connect With a Mentor Billing EngineerCommented:
it is preferrable to avoid the *, because
* you gain a minimum avoiding sql to resolve the * into the actual column list
* you should only return those columns (and rows) that you really need

indexes will not be ignored due to this, but you have indexes that contain all the fields that are in the list, the table page does not need to be looked up.
0
 
Aneesh RetnakaranDatabase AdministratorCommented:
pcarrollnf,
> Is there a degradation in performance or are the indexes ignored by
> using the d.* and a.* instead of the actual column names

there wont be any degradation in performanxce
0
 
TimCotteeConnect With a Mentor Head of Software ServicesCommented:
Hi pcarrollnf,

The indexes are not ignored, however there is a slight degradation in performance because the server needs to enumerate the fields. When you specify fields, there is nothing that needs to be done, however if you use * then the server must first get the full field list then prepare the actual query. This does ever so slightly (and possibly not even measurably) degrade your performance. However once the field list is obtained then the normal execution plan will be generated and used.

Tim Cottee
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.