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 > Why is it using index?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-08-09, 15:48
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Why is it using index?

Not sure why, but someone was running a select * on a 900+ million record table and it was taking a lifetime.

8 partitions. Looking at the table I see 13 indexes. Explain path shows that select * with no where is using an INDEX ? This is the smallest index based on the leaf size and only has 27 unique values. Yes I know, why have an index with only 27 values on a billion record table. Don't ask me. I am not the one that designed it, nor the one to delete it.

Why is it using the index when you are fetching ALL records? What am I missing. In QA it does tbs as it should. Diff, in QA table only have 70 mil.

Thank you

BTW. This is a dec(15) column mid field.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #2 (permalink)  
Old 09-08-09, 16:19
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
Cougar8000, is that the entire query "Select * From table-name"? No Where clause, Join, Sub-Select, Order By, Union, etc.?

If it is just a Select * From Table, I agree that no index access would be needed or desired.
Reply With Quote
  #3 (permalink)  
Old 09-08-09, 16:20
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
yes

Select * from tables

Any idea why it is trying to use a bogus index?
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #4 (permalink)  
Old 09-08-09, 16:36
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
I'm sure the answer is in the access plan, which you chose not to share with us. I would expect to see a parallel list prefetch there, and the easiest way to prepare the RID list for prefetch is to scan the smallest index.
Reply With Quote
  #5 (permalink)  
Old 09-08-09, 16:36
Stealth_DBA Stealth_DBA is offline
Registered User
 
Join Date: May 2009
Posts: 472
Not really. Has the table been Reorged recently? If there has been a lot of Changes (especially Deletes), DB2 might think it is better getting the RIDS from an Index instead of reading a lot of empty (all rows deleted) pages.

That is about the only thing I think of as a (really wild) suggestion.
Reply With Quote
  #6 (permalink)  
Old 09-08-09, 16:48
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Nick,

Access Plan:
-----------
Total Cost: 6.17634e+07
Query Degree: 1

Rows
RETURN
( 1)
Cost
I/O
|
7.40797e+08
DTQ
( 2)
6.17634e+07
1.28043e+07
|
9.25997e+07
FETCH
( 3)
6.15297e+07
1.28043e+07
/------+------\
9.25997e+07 9.25997e+07
RIDSCN TABLE: FCTFDSDB
( 4) FACT_FINC_PRFT_AND_LOS
267230
40585
|
9.25997e+07
SORT
( 5)
262625
40585
|
9.25997e+07
IXSCAN
( 6)
103187
40585
|
9.25997e+07
INDEX: FCTFDSDB
INX_FFPL_POPINFO


This table is truncated and then reloaded on a monthly basis. No deletes in between.

We have another copy of this table in QA as I just found out that has a full set of data and same indexes as prod and it is doing TBS.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #7 (permalink)  
Old 09-08-09, 16:54
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
it is a bitch when you are not given a right info

Now I am told that developers ADD 5 mil every month and then update all of the records.

So, that seams to support what Nick is saying.

Thanks guys.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #8 (permalink)  
Old 09-08-09, 17:29
n_i n_i is offline
:-)
 
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
If you want to discourage the prefetch, try turning SEQDETECT off or play with PREFETCHSIZE and the block-based pool. However, not running SELECT * FROM A900MROWSTABLE usually yields better results...
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