Optimize the number of columns that are selected with SELECT statements

For each column in the SELECT statement, the database manager retrieves the data from the underlying table and maps it to a host variable in the application program. 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 required for the application. This technique is especially important for index-only access, or if all the columns participate in a sort operation (as in SELECT DISTINCT and SELECT UNION).

This technique is also important when considering index only access. You minimize the number of columns in a query and increase the odds that an index can be used to completely satisfy the data request.