Midrange News for the IBM i Community


Posted by: Bob Cozzi
Rogue Programmer
Cozzi Productions, Inc.
Chicagoland
SQL RUN FASTER Option
has no ratings.
Published: 03 Feb 2015
Revised: 03 Feb 2015 - 3362 days ago
Last viewed on: 16 Apr 2024 (3713 views) 

Using IBM i? Need to create Excel, CSV, HTML, JSON, PDF, SPOOL reports? Learn more about the fastest and least expensive tool for the job: SQL iQuery.

SQL RUN FASTER Option Published by: Bob Cozzi on 03 Feb 2015 view comments

There's an option that came about in V5R4 but wasn't working until V6R1 and later. That option is for SELECT statements in SQL. If you specify your SELECT statement and follow it with the OPTIMIZE FOR clause, it will return that "first page" of records much faster.

SELECT A,B,C FROM CUSTMAST WHERE STATE in ('IL', 'IN', 'IA')  
ORDER BY STATE 
OPTIMIZE FOR 40 ROWS

Return to midrangenews.com home page.
Sort Ascend | Descend

COMMENTS