optimize-clause

The optimize-clause tells the database manager to assume that the program does not intend to retrieve more than integer rows from the result table. Without this clause, or with the keyword ALL, the database manager assumes that all rows of the result table are to be retrieved. Optimizing for integer rows can improve performance. The database manager will optimize the query based on the specified number of rows.

Read syntax diagramSkip visual syntax diagram
>>-OPTIMIZE FOR--+-integer-+--+-ROW--+-------------------------><
                 '-ALL-----'  '-ROWS-'   

The clause does not change the result table or the order in which the rows are fetched. Any number of rows can be fetched, but performance can possibly degrade after integer fetches.

The value of integer must be a positive integer (not zero).