Observation: Sort Invoked for DISTINCT

You coded a DISTINCT clause which invokes a sort unless a unique index exists for the columns against which you applied the DISTINCT. If you have defined a unique index, DISTINCT is unnecessary because all values in the columns are unique. In addition, if you use GROUP BY instead of DISTINCT, DB2 can use a non-unique index to retrieve all unique values without invoking a sort.

The select list in example below specifies DISTINCT to return unique values of C1:

SELECT DISTINCT 
C1 
FROM 
T1 

You can recode that statement using GROUP BY clause, as shown below:

SELECT
C1 
FROM 
T1 
GROUP BY 
C1