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 > Explain Plan Question

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-25-07, 10:31
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Explain Plan Question

DB2 UDB V8.1 FP 14/AIX 5.3
DB has 8 logical partitions

One of the SQL runs for an unusually long time so when I check the App.Shap I found out that SQL is performing tablescan of big table.

Here are few lines from app.snap
Rows deleted = 0
Rows inserted = 0
Rows updated = 0
Rows selected = 0
Rows read = 1829438580
Rows written = 1205012047


But I ran db2expln to check the plan but as per the plan the query should perform tablescan as below.
RETURN
( 1)
|
BTQ
( 2)
|
NLJOIN
( 3)
/---------------------------/ \---------------------------\
BTQ FILTER
( 4) ( 8)
| |
GRPBY HSJOIN
( 5) ( 9)
| /---------------------/ \---------------------\
FETCH NLJOIN BTQ
( 6) ( 10) ( 22)
/ \ /-------------------/ \-------------------\ |
IXSCAN Table: BTQ FETCH FETCH
( 6) CARD ( 11) (----) ( 23)
| DWH_CONTROL | /---------/ \----\ |
Index: FETCH RIDSCN Table: IXSCAN
ETL ( 12) ( 15) CARD ( 23)
TX1 /-/ \ +--------------------+--------------------+ TRANSACTION |
IXSCAN Table: SORT SORT SORT Index:
( 12) SMTUMT ( 16) ( 18) ( 20) SYSIBM
| CLAIM_TYPE | | | SQL060227125909990
Index: IXSCAN IXSCAN IXSCAN
SMTUMT ( 17) ( 19) ( 21)
CLAIM_TYPE_LAAMUI / \ / \ / \
Index: Table: Index: Table: Index: Table:
CARD CARD CARD CARD CARD CARD
TX3 TRANSACTION TX3 TRANSACTION TX3 TRANSACTION


Question:
As per explain plan SQL should use index scan but the query goes for tablescan. I cannot understand this situation. Can you please share your thoughts on this.
Reply With Quote
  #2 (permalink)  
Old 04-25-07, 10:32
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Typo Error on previous post:
But I ran db2expln to check the plan but as per the plan the query should perform indexscan (not tablescan)
Reply With Quote
  #3 (permalink)  
Old 04-25-07, 11:24
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Are you sure that it is doing a tablescan? Just because the number of rows read is large does not necessarily mean a table scan. Can you supply the SQL of the query and the DDL for the tables and indexes involved? Also the cardinality of the tables and how many rows you think it should be reading through.

Andy
Reply With Quote
  #4 (permalink)  
Old 04-25-07, 18:19
db2udbgirl db2udbgirl is offline
Registered User
 
Join Date: Mar 2006
Location: Tuticorin, India
Posts: 100
Andy: I'm unable to post all the details over this forum (as I think that i got deleted automatically. Do I have any other options ?
Reply With Quote
  #5 (permalink)  
Old 04-26-07, 07:57
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
1) What is the cardinality of the table?
2) how many rows do you expect to receive from the query.
3) how many other tables are joined in the query and how? How are they accessed?
4) are runstats current?
5) how volatile are the tables (inserts, updates, deletes)?

Andy
Reply With Quote
  #6 (permalink)  
Old 04-27-07, 10:26
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
db2udbgirl, Can you post the explain query as an attachment - notepad or word file ?

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #7 (permalink)  
Old 04-27-07, 10:28
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
Can you please PM the exact details of the problem you faced when trying to post "all details"

Sathyaram

Quote:
Originally Posted by db2udbgirl
Andy: I'm unable to post all the details over this forum (as I think that i got deleted automatically. Do I have any other options ?
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
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