Coding SQL statements to avoid unnecessary processing

By keeping your SQL statements simple, you can limit the amount of processing that they require.

Procedure

To get the best performance from SQL statements:

  • Select only columns that are included in the result set or used to calculate the result set.
  • Use GROUP BY and ORDER BY clauses only when the grouping and order of the returned data are important.
    Important: When an ORDER BY clause is not specified, DB2® might return data in any order.
  • Start of changeSpecify the DISTINCT option only when the result set must not contain duplicate rows.End of change