Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399

    Unanswered: fetch gives different number of records

    when we run fetch from the application program (C++) we get 18 recs, if I run an sql statement I get 200 records. From the top of your head what could be the problem.

    We get no error messages. I've done reorg and runstats on all tables and indexes used in the query and it did not make any difference. db2diag did not detect any problems on the database at the time when program was run.

    Thanks
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  2. #2
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    We fixed it. I forgot abt rebind after all reorgs and runstats. So we did re-bind and it got fixed. Still have no idea what do all this have to do with the results of the query. I thought it would affect only perfomance, not the result.
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  3. #3
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    I don't know what exactly you are doing and where you got your numbers from, but I could imagine that one number shows how many records you fetched (which is correct) and the other is an estimate of how many rows DB2 believes it will return for the query. The latter number is just an estimate and, thus, by no means required to be correct.

    If your application relies on a correct count of rows before fetching the rows, you may have a design problem. Because: counting all rows before fetching executes the query twice, which is (a) slow, and (b) not guaranteed to be correct either, except on isolation level RR, which reduces concurrency.

    p.s: It would be helpful to know which DB2 version you are using on which platform.
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  4. #4
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    p.s: It would be helpful to know which DB2 version you are using on which platform.

    Knut, it's in my signature after my nick
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  5. #5
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    Well, I de-selected "Show Signature" in the profile, which is why I don't see those details. ;-)
    Knut Stolze
    IBM DB2 Analytics Accelerator
    IBM Germany Research & Development

  6. #6
    Join Date
    Dec 2008
    Location
    Toronto, Canada
    Posts
    399
    Quote Originally Posted by stolze
    Well, I de-selected "Show Signature" in the profile, which is why I don't see those details. ;-)
    sorry, Knut, it's
    DB2 v8.2 ESE (FP10,64bits) on UNIX/AIX v5.3
    DB2 9.5/9.7 on Unix/AIX 6.1/Linux

  7. #7
    Join Date
    Jan 2007
    Location
    Jena, Germany
    Posts
    2,721
    That leaves the question what the 2 ways are that you use to get the row count.
    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
  •