
When you say DB2 commands, are you asking about SQL statements? When you ask about access a row, which DB2 statement would you use? Using either DB2 commands or VSAM KSDS, how would you measure an index scan, especially how do you mean it for VSAM?
The comparisons you’re asking about don’t make complete sense. Generally, a major point about SQL is that it operates on “sets” of data. An operation such as “access a row” isn’t really appropriate for SQL, although it can be done. But just because something can be done doesn’t mean that it should be.
VSAM is often better when specific rows need individual changes, and SQL is better when multiple rows (a “set” of rows) need the same changes. If it’s important, use the tool that is appropriate for the task.
Also, this question shows up tagged with both ‘z/OS CPU consumption’ and ‘AS/400 DB2′. Did you add those tags? Since they refer to radically different platforms, I can’t make sense of them. What are you trying to determine? Is this a question about a comparison between platforms?
Tom

Another point is that SQL can do so much more than just “read a record” like VSAM.
Any comparison between DB2 (SQL) and a VSAM read would be faulty.
I remember having this and similar discussions back 25-odd years ago when DB2 was coming into our shop for the first time. Many people, including me for a while, focused on things like physical I/O when trying to compare DB2 to VSAM.
DB2 is *not* an access method; VSAM is.
DB2 is a relational database management system; VSAM is not.
You must compare all other aspects of using an RDBMS.
I think the benefits of using an RDBMS over VSAM are huge, in most cases. (yes, VSAM still has place.)
Look on the bright side. VSAM KSDS is used by DB2 for his Boot Strap data Set. And the page spaces are VSAM Linear data sets. After all, some sort of file has to be used.
Staff must lose conventional data processing mindset and learn relational processing. Do not replace VSAM with DB2 if you will not embrace the RDBMS and all of its functionality. Learn DB2, learn SQL, and benefit from all it can do for you.
Good luck.
Steve

Thank you for your comments Steve,
I have not been clear about my question once we do not want compare technically DB2 and VSAM because we know both very well but there is something more than the technical analysis and my company needs now set a budget for likely growth of the CPU costs after application systems conversion from VSAM to DB2, only this.
We will go to develop two versions of the same transaction online (VSAM KSDS and DB2 versions) and we will run both in parallel some thousand times and will compare the CPU consumption.
Our expectation is that the CPU consumption difference is minimal because despite DB2 is “heavier”, its better abilities of data cache and search engines will compensate itself.
One more time, thanks.
Best regards.
Abel.

The process basically will consist of converting the Cobol/VSAM commands to SQL commands:
- Cobol OPEN <file> will be eliminated
- Cobol CLOSE <file> will be replaced by SQL CLOSE CURSOR
- Cobol START <file> will be replaced by SQL DECLARE / OPEN CURSOR
- Cobol Random READ will be replaced by SQL SELECT/INTO (eg the original question)
- Cobol REWRITE will be replaced by SQL UPDATE
- Cobol WRITE will be replaced by SQL INSERT
- Cobol DELETE will be replaced by SQL DELETE
If that is the intended architecture of a majority of the programming, then VSAM is likely to be a better choice. That structure is effectively a misuse of SQL.
SQL is not intended to handle record-by-record processing even though it can be done as you suggest. Doing so causes instruction flow to continually switch between running program instructions then making calls down into DB2 routines (for each individual I/O operation) before coming back up into program instructions again.
SQL is intended to have a single SQL statement process many rows at once. That is, SQL should process a “set” of records whenever possible. That’s what it is optimized to do. The code should drop into the DB2 routines only once and stay there until finished — especially assuming that performance is the objective.
By using a cursor and progressing a row at a time, you are perhaps doing little more than adding an additional layer onto your I/O.
IMO (all of this is IMO), it might have become a biased comparison in the proposed architecture.
Tom

















