Page 1 of 1

Query on Usage of Unique Index

PostPosted: Fri Jul 13, 2012 6:37 pm
by chandurokzz
Hi,

Consider Table-a is having col1,col2,col3,col4 as columns.
unique index is created on col3 and col4

select col1 from table-a
where col3 > :value:
and col4 = :value:

will the above query use the full index in the tablespace scan?

Please help me on this.

Thanks in advance

Regards,
Chandu

Re: Query on Usage of Unique Index

PostPosted: Fri Jul 13, 2012 7:09 pm
by GuyC
It will use all fields in the index to determine wether or not it needs to retrieve the data. but it will need to read all index entries starting from col3 > :value. (MatchCols = 1)
At least that is how it works unil now, IBM is constantly finding faster ways =>
On DB2 10 LUW (and maybe soon in DB2 z/OS) there is another type of accessmethod called "JUMP SCAN" where it will actually skip thru the index, landing on each col4 = :value.
http://justdb2chatter.blogspot.co.uk/20 ... 0-luw.html

Re: Query on Usage of Unique Index

PostPosted: Mon Jul 16, 2012 9:35 am
by chandurokzz
Thanks GuyC :)