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 > Access Path Problem in EXPLAIN

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-05-04, 07:54
xamar xamar is offline
Registered User
 
Join Date: Apr 2004
Posts: 39
Access Path Problem in EXPLAIN

DB2 V7.1 in OS/390

Hi,

I have a table TABA with 8 columns.
There is a unique composite index on colno 7,9,5,6 in that sequence.

when i do an explain on the following query,

select col5, col6
from TABA
where col7= ? and
col9=?

I get indexed access with matchcols as 2. And Index only='N'

Why is index only='N' here? What is the need to access tablespace?

I tried putting col5 and 6 in the where clause, that just increases the matchcols to 4 but Indexonly is still 'N'

What could be the reason?

table has around 10 million rows. Stats are mostly upto-date.

xamar
Reply With Quote
  #2 (permalink)  
Old 06-05-04, 08:11
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
What are the data types for col5 and col6? Is there any compression or encryption being used? An edit procs or field procs?

Try substituting literals for the ? in the explain query. It may just be a bug in the explain.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 06-06-04, 05:53
xamar xamar is offline
Registered User
 
Join Date: Apr 2004
Posts: 39
Re

I think the data types are char. About the other thing e.g. compression and procs, i will get back on monday. But do they make any difference?

And does it help substituting literals for '?' ? They are actually host variable.

thanks for replying though!
xamar
Reply With Quote
  #4 (permalink)  
Old 06-07-04, 01:48
momi momi is offline
Registered User
 
Join Date: Jun 2004
Posts: 1
Hi
i'de check the types of the columns,
if it is varchar, then you should check a zparm name RETVLCFK,
it tell's db2 if it can retrieve varchar values from index or has
to read them from the data pages. If it is set to NO,
then DB2 will never read varchar values from the index and will
always read the data pages

bye
Reply With Quote
  #5 (permalink)  
Old 06-07-04, 03:37
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I would be careful before changing RETVLCFK:

From Redbook DB2 for z/OS and OS/390 Version 7 Performance Topics:

"In DB2 V6, you could only get an index-only access in this case by specifying RETVLCFK=YES. Many sites do not want to set the parameter to YES because it impacts every application program that includes in its select list a VARCHAR column that is an index key column. If an index-only access is chosen by DB2, then the VARCHAR values are returned to the application program padded with blanks and with the column length set to the maximum. When the VARCHAR is returned from the data row it is returned as a true variable length value without padding. Not all programs can handle this access path dependent variation in how data is returned from a SELECT."

I believe this is not issue with version 7 and RETVLCFK does not have to be set to YES to get index only access.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #6 (permalink)  
Old 06-07-04, 11:26
xamar xamar is offline
Registered User
 
Join Date: Apr 2004
Posts: 39
Reply

OK, here is the data.

col5 is INTEGER
col6 is TIMESTAMP
col7 is integer
col9 is char

NO varchar

No fieldproc or edit proc is defined on any of those 4 columns.

No compression. Does this matter? No encryption.

I tried substituting literals for '?' . It gives the same result in EXPLAIN.

I can't believe I found a bug in IBM's EXPLAIN

xamar
Reply With Quote
  #7 (permalink)  
Old 06-07-04, 16:41
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
I would check with the IBM site or IBM support for an APAR. Of course, the SQL your posted is not the actual SQL that you used, nor did you show the actual DDL of table and index, so there may be some other explination.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #8 (permalink)  
Old 06-08-04, 03:19
xamar xamar is offline
Registered User
 
Join Date: Apr 2004
Posts: 39
Re

I can't post the exact table structure due to security constraints etc.

I thought i posted enough information. Its true that there is a possibility that missed something.

One of them may be that the table has 2 more indexes. Some of them involve these columns. But since it doesn't use them for this query, I thought its not useful here.

There is field proc too but on a column that is not involved here.

So anyway, thanks Marcus and Momi!
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