Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2006
    Posts
    115

    Question Unanswered: [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?

  2. #2
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

  3. #3
    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.

  4. #4
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •