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 > Record Selectivity > 100%?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 03-03-08, 18:26
djschmitt djschmitt is offline
Registered User
 
Join Date: Nov 2002
Location: Omaha, NE
Posts: 23
Record Selectivity > 100%?

When taking a database snapshot I have two databases showing their record selectivity being greater than 100% - how is this possible?

Rows deleted = 39389
Rows inserted = 50490
Rows updated = 61096
Rows selected = 58807271
Rows read = 356136828
Reply With Quote
  #2 (permalink)  
Old 03-03-08, 19:08
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
Anything seems to be possible at the end of the work day, especially on Monday.

Try looking at the problem again tomorrow morning.
Reply With Quote
  #3 (permalink)  
Old 03-04-08, 04:58
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
What makes you think that the selectivity is greater than 100%?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #4 (permalink)  
Old 03-04-08, 11:18
djschmitt djschmitt is offline
Registered User
 
Join Date: Nov 2002
Location: Omaha, NE
Posts: 23
Ha! This has been occurring for quite a while and I haven't found anything in my research so it was time to post here Here's the snapshot for yesterday...

Rows deleted = 290529
Rows inserted = 368325
Rows updated = 57111
Rows selected = 5232382
Rows read = 3495144

stolze, I'm saying that because the number of records selected/records read is greater than 100% (I've heard this calculation defined as 'selectivity' before)

5232382/3495144 = 149%
Reply With Quote
  #5 (permalink)  
Old 03-04-08, 13:15
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I believe it reflects index-only access cases. Index access is not included in "rows read" but the rows returned to the application are still counted in "rows selected".
Reply With Quote
  #6 (permalink)  
Old 03-04-08, 13:35
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Now that would be a strange way to define "selectivity". Selectivity is the amount of rows that qualify a certain predicate. Whether those rows are read from the pages or not (like with index-only access) is irrelevant.

If you look up "Rows read", you find:
Quote:
This is the number of rows read from the table.
And "Rows selected" is:
Quote:
This is the number of rows that have been selected and returned to the application.
I haven't tested this, but I'd believe that join operations could easily influence those numbers. I.e. a row may be read only once and joined to several other rows, causing it to be counted multiple times in the "Rows selected" section. Also, if you have some table functions that generate data on the fly, it could be that those rows are not counted in "Rows read". Add to that what n_i mentioned about index-only queries, and the whole issue seems less suspicious.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 03-05-08, 10:11
azs0309 azs0309 is offline
Registered User
 
Join Date: Jan 2008
Posts: 88
Hi. i tried to test what n_i has suggested , and I found its true . but i couldnt get the reason why??
Reply With Quote
  #8 (permalink)  
Old 03-05-08, 11:00
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
If a query is answered based on an index only, DB2 doesn't read any rows from a table. Hence, it must not count those rows as "Rows read".
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #9 (permalink)  
Old 03-05-08, 11:07
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
If I am not mistaken that number represent # of rows brought back by the app. If that number is greater then your total records then your app is doing a cartesian join. Generally it is not a good thing.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #10 (permalink)  
Old 03-05-08, 12:00
djschmitt djschmitt is offline
Registered User
 
Join Date: Nov 2002
Location: Omaha, NE
Posts: 23
Thanks for the clarification on my terminology, Stolze. I have probably been confusing my terms over the years

n_i, you're probably right on this one as this is for an ERP application and there seem to be indexes for every possible scenario. That might also explain why suddenly another of my databases which had a similar scenario is now performing terribly and this ratio has gone way out of whack. Thanks for your help.
Reply With Quote
  #11 (permalink)  
Old 03-05-08, 15:43
azs0309 azs0309 is offline
Registered User
 
Join Date: Jan 2008
Posts: 88
but isnt that good that everything is being picked by indexes...i dont see any harm in rows selected is greater than rows read..
Reply With Quote
  #12 (permalink)  
Old 03-05-08, 15:45
azs0309 azs0309 is offline
Registered User
 
Join Date: Jan 2008
Posts: 88
but isnt that good that everything is being picked by indexes...i dont see any harm in rows selected is greater than rows read..
Reply With Quote
  #13 (permalink)  
Old 03-05-08, 18:51
djschmitt djschmitt is offline
Registered User
 
Join Date: Nov 2002
Location: Omaha, NE
Posts: 23
Yes, it has been a very good thing however last week suddenly the number of Rows Read shot up while the number of Rows Selected stayed constant. So I had a very good scenario and then suddenly last week it got very bad. I was trying to look for an explanation of the scenario when things were good to see if I could find some reasons for what happened.

I have a SQL statement that I think is the culprit for the incraese but it was running even when times were good. So with the explanation by n_i I'm going to explore why DB2 is no longer choosing index only access and instead performing a table scan.
Reply With Quote
  #14 (permalink)  
Old 03-06-08, 05:02
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by azs0309
but isnt that good that everything is being picked by indexes...i dont see any harm in rows selected is greater than rows read..
That depends. Every index you add to your system must be maintained by DB2 on INSERT/UPDATE/DELETE operations. So if you system is biased to mostly queries, then adding indexing may well offset the additional overhead introduced by maintaining those indexes. If you have mostly data modifications, you have to carefully balance the amount of indexes you create.
__________________
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