This statement indicates that the query must sort the intermediate results before returning them to the user. Queries that specify DISTINCT, as well as queries that have an ORDER BY clause that cannot use an available index, require an intermediate sort. As stated earlier, the results are put into a worktable, and the worktable is then sorted.
The following example demonstrates a query that requires a sort:
SELECT DISTINCT state FROM stores
STEP 1 The type of query is INSERT The update mode is direct Worktable created for DISTINCT FROM TABLE stores Nested iteration Table Scan TO TABLE Worktable 1 STEP 2 The type of query is SELECT This step involves sorting FROM TABLE Worktable 1 Using GETSORTED Table Scan