Optimize the number of columns that are selected with SELECT statements

The number of columns that you specify in the select list of a SELECT statement causes the database manager to retrieve the data from the underlying tables and map the data into host variables in the application programs. By minimizing the number of columns that are specified, processing unit resource usage can be conserved.

Even though it is convenient to code SELECT *, it is far better to explicitly code the columns that are actually required for the application. This is especially important if index-only access is wanted or if all of the columns will participate in a sort operation (as happens for SELECT DISTINCT and for SELECT UNION).

This is also important when considering index only access, since you minimize the number of columns in a query and thereby increase the odds that an index can be used to completely satisfy the request for all the data.

Related information
select-statement