Home All Groups Group Topic Archive Search About
Author
20 May 2006 1:51 AM
Howard
In a case where I'm not sure how many columns Im going to use should I just
use
select * from table1
or
select col1, col2, col3, col4... from table1

Is there any disadvantage for using select * in terms of performance or
security?

Thanks,
Howard

Author
20 May 2006 11:52 AM
Dan Guzman
The Best Practice is to specify only those columns you actually use.  This
will give the optimizer more flexibility, such as choosing covering
non-clustered indexes, and also reduce network bandwidth requirements.  The
column list technique also provides a more well-defined application
interface that doesn't change when columns are added to tables.

From a security perspective, a column list provides vertical partitioning so
that data is selectively exposed.

--
Hope this helps.

Dan Guzman
SQL Server MVP

Show quote
"Howard" <howdy0***@yahoo.com> wrote in message
news:%238Bik$6eGHA.2076@TK2MSFTNGP04.phx.gbl...
> In a case where I'm not sure how many columns Im going to use should I
> just use
> select * from table1
> or
> select col1, col2, col3, col4... from table1
>
> Is there any disadvantage for using select * in terms of performance or
> security?
>
> Thanks,
> Howard
>
>

AddThis Social Bookmark Button