Sunday, January 25, 2009

DB2 "OPTIMIZE FOR 1 ROW"

Use this clause to avoid sorts - You can influence the access path most by using OPTIMIZE FOR 1 ROW.

OPTIMIZE FOR 1 ROW tells DB2 to select an access path that returns the first qualifying row quickly. This means that whenever possible, DB2 avoids any access path that
involves a sort.

In "OPTIMIZE FOR n ROWS", if you specify a value for n that is anything but 1, DB2 chooses an access path based on cost, and you won't necessarily avoid sorts.

No comments: