Hi,
I tried running an Explain on this queries. Let me tell how and what i did this.
I ran an EXPLAIN in Production on one of the tables where it had the latest statistics. I have my own Plan table and DSN tables in PROD.
Table name: ICB_data
column names:
Tms --> TIMESTAMP NOT NULL WITH DEFAULT
REFNR --> CHAR(10) NOT NULL
and other columns which we dont need.
There is an Unique index built on TMS and REFNR in the order,
COLNAME ORDER
TMS A
REFNR A
I ran DB2 Explain on the below four queries for this table.
EXPLAIN PLAN SET
QUERYNO = 96
SELECT
REFNR, TMS FROM ICB_DATA
WHERE REFNR = ?
EXPLAIN PLAN SET QUERYNO =
97
SELECT
TMS FROM ICB_DATA
WHERE REFNR = ?
EXPLAIN PLAN SET QUERYNO =
98
SELECT
REFNR, TMS FROM ICB_DATA
WHERE TMS = ?
EXPLAIN PLAN SET QUERYNO =
99
SELECT
REFNR FROM ICB_DATA
WHERE TMS = ?
Once I ran explain, I queried the DSN_STATEMENT table to check the COST_CATEGARY, Estimated milliseconds and Estimated Serivce units. I just had hope that the columns milliseconds and service units will be different in each case however it was not the case.
I dont understand why the queires 96 & 97 are going with MATCHCOLS = 0 though there is an index built on REFNR. I see it is the last column on the index however the ACCESSTYPE is still I. All the queries says it has INDEX ONLY ACCESS.
Here is the result from Dsn statement table.
EXPLAIN COST
QUERYNO TIME CATEGORY PROCMS PROCSU
-------- -------------------------- -------- ----------- -----------
96 2007-12-27-13.40.07.930000 A 173 4206
97 2007-12-27-13.41.25.100000 A 173 4206
98 2007-12-27-13.43.02.940000 A 1 1
99 2007-12-27-13.43.18.690000 A 1 1
So Is there any difference to measure..?. Is there any other place we can see more information..? I just did what all i could do

as am not expertise.
Please let me know your comments on this. Thanks a lot for your time.