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 > Index selection db2 sql queary

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 12-15-06, 03:59
baski76 baski76 is offline
Registered User
 
Join Date: Dec 2006
Posts: 2
Index selection db2 sql queary

Hi All,

Can any one provide me with some suggestion how to force db2 to select an index
i have a following sql for which there is a full table scan even though we have index matching the where clause

SELECT T9222.CNNO,
T9222.TRANNO,
T1015.CTRIBADT
FROM DB2LPP.TLP9222 T9222,DB2LPP.TLP9015 T1015
WHERE T9222.TRTYP = 'AL'
AND T9222.TRSTATCD IN ('SM','SI','WB','FL')
AND T9222.TRANNO = T1015.TRANNO
Reply With Quote
  #2 (permalink)  
Old 12-15-06, 09:31
ARWinner ARWinner is offline
Registered User
 
Join Date: Jan 2003
Posts: 3,575
Please provide DB2 version, OS version, and DDL for the tables and indexes in question. Also insure that you have don runstats on table and indexes.

Andy
Reply With Quote
  #3 (permalink)  
Old 12-18-06, 02:32
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
provide index definition and access plan.
Grofaty
Reply With Quote
  #4 (permalink)  
Old 12-18-06, 03:44
baski76 baski76 is offline
Registered User
 
Join Date: Dec 2006
Posts: 2
we hav an index for this table,with follwing columns

TRTYP
TRSTATCD
TRANNO
CLNTID
but this sql is not picking up this index,insted it gos for a table scqane:

access path:
Line 01 Data accessed from the table
SQL operation: SELECT statement
In......Table: DB2TEST.TLP9222
Access Method: Table scan using sequential prefetch.
Lock: Intent share
Reply With Quote
  #5 (permalink)  
Old 12-18-06, 05:18
Peter.Vanroose Peter.Vanroose is offline
Registered User
 
Join Date: Sep 2004
Location: Belgium
Posts: 1,079
A possible reason could be that, according to the statistics, the combined TRTYP = 'AL' & TRSTATCD IN ('SM','SI','WB','FL') occur too often to justify index use.
Or maybe the index is non-clustering and the RID pool is too small.
__________________
--_Peter Vanroose,
__IBM Certified Database Administrator, DB2 9 for z/OS
__IBM Certified Application Developer
__ABIS Training and Consulting
__http://www.abis.be/
Reply With Quote
  #6 (permalink)  
Old 12-18-06, 06:54
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Hi,
have you tried creating an index this way:
create index db2test.test on DB2TEST.TLP9222 (TRANNO, trtyp, trstatcd)

Is there any index on table DB2LPP.TLP9015?

Try also running distributed statistic: runstats on table xxx with distribution and detailed indexes all.

Please also provide all access plan data.

Hope this helps,
Grofaty
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