If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > [AS400] Would cursors affect performance on DB2 & AS400?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 05-17-07, 21:25
tingshen tingshen is offline
Registered User
 
Join Date: Oct 2006
Posts: 115
Question [AS400] Would cursors affect performance on DB2 & AS400?

I am planning to embed a cursor in one of my cobol programs.

Usually when we "open" the cursor, would the view/result set stored in the system memory/program memory or it would actually hit the DB2 everytime we fetch?

Is it better to use embedded cursors to handle data extraction or cobol itself?
Reply With Quote
  #2 (permalink)  
Old 05-20-07, 09:56
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
I can't speak much for AS400, but usually cursors are the only way to retrieve data from an RDBMS. So you usually don't have any choice. AS400 may be different because you could possibly also access the data with file i/o operations.

Generally spoken, DB2 uses blocked cursors if possible, i.e. multiple rows are retrieved and send from the server to the client together. Thus, no new network round trip is incurred on each fetch - only when the rows cached at the client are exhausted. However, if you have a FOR UPDATE cursor, DB2 can't do that easily because the server has to know which row you want to update, i.e. it has to know the status. One approach chosen by DB2 LUW is, for example, to avoid block fetch in such cases.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #3 (permalink)  
Old 05-20-07, 10:43
tingshen tingshen is offline
Registered User
 
Join Date: Oct 2006
Posts: 115
my case has no update involved. So, is it advisable to still use Cursor? yup, we can do direct I/O to the file too, but the coding is going to be longer, in Cobol.
Reply With Quote
  #4 (permalink)  
Old 05-22-07, 09:49
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Which other options do you have? As I said: through SQL, you only have cursors to access the data (apart from SELECT INTO etc.) So if you don't want to use direct I/O, I don't see how this question could arise in the first place.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On