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 > fetch gives different number of records

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-09-09, 13:59
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Canada
Posts: 370
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 v9.5 ESE on AIX v6.1
Reply With Quote
  #2 (permalink)  
Old 01-09-09, 14:39
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Canada
Posts: 370
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 v9.5 ESE on AIX v6.1
Reply With Quote
  #3 (permalink)  
Old 01-12-09, 04:38
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,568
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
Reply With Quote
  #4 (permalink)  
Old 01-12-09, 21:51
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Canada
Posts: 370
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 v9.5 ESE on AIX v6.1
Reply With Quote
  #5 (permalink)  
Old 01-13-09, 04:32
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,568
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
Reply With Quote
  #6 (permalink)  
Old 01-13-09, 09:34
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Canada
Posts: 370
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 v9.5 ESE on AIX v6.1
Reply With Quote
  #7 (permalink)  
Old 01-13-09, 10:14
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,568
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
Reply With Quote
Reply

Thread Tools
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