560 pts.
 SQL vs RPG
Which is faster? Getting a certain number of records using a cursor with SQL or using native I/O's SetLL & ReadE?

Software/Hardware used:
ASKED: July 28, 2009  2:56 PM
UPDATED: July 29, 2009  2:35 AM

Answer Wiki:
Sometimes SQL can be faster and sometimes not. RPG uses the views of the file (logical view or physical if file is keyed). If the view is helpful in getting what you want or need is a relatively small number of steps, it will appear to be fast. If you have a view that does not lend itself well to the application, then it will appear very slow. For example: You wish to get every address in a customer file with the street address "555 Main St." Using RPG, you will have to set up a logical view of the file using the street address, then set lower limite and read until the street address does not begin with 555. Using SQL, you can access only the spacifics you want, that is "555 Main St." SQL is smart enough to find an access path to the data. If one exists, then it will use it. This is when SQL is fast. But, if it doesn't find one then it creates one temporarily. This is when it is slow. So it is up to the programmer to know what is available and choose wisely.
Last Wiki Answer Submitted:  July 28, 2009  7:20 pm  by  Rick53   110 pts.
All Answer Wiki Contributors:  Rick53   110 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

I do not see how SQL can be faster in this scenario.

 560 pts.

 

hi Rick,

thanks for the answer.

However, RPG can access only the specific too. This is when you use the logical file and then use a key for “set lower limits” and a “read equal”.

I want to know specific instances or samples when and where SQL will be faster. I want to implement it in my coding if it really is faster.

Thanks!

 560 pts.