"Andr? Queiroz" <an***********@netcabo.pt> wrote in message
news:e5**************************@posting.google.c om...
Hi,
I have a table with 10M records and col A has a index created on it.
The data on that table has the same value for col A on all 10M
records. After that I insert diferent values for that column but my
queries do not use the index I created for that column.
Is there any way I can force the usage of the index or to ommit a
value on the index creation, like 0 (zeroes) or spaces?
Thanks in advance,
André Queiroz
Try doing a reorg of the index (or reorg table with indexes) and then
running runtstats with full statistics. That will let DB2 know that the new
values of ColA are available. However, DB2 may still not use the index
unless there are at least 20 different values present, and even then it may
not use it.
When DB2 decides to use an index for performance reasons (which is different
than using an unique index to guarantee uniqueness) it does so to be able to
ignore certain pages of data rows. Data is normally stored in 4K pages, so
if the row length is 200 bytes, there are 20 rows per page. Assuming a
random distribution of ColA in the table (and the table is not clustered on
ColA), there would need to be more than 20 unique values of ColA in order
for DB2 to skip a page in the tablespace and benefit by using the index.
Otherwise, just scanning the tablespace is faster, especially since
sequential prefetch can be used.
If your reorg the data and run full statistics, DB2 will almost always chose
the most efficient access path, even if DB2 decides that using an index is
not the most efficient method.
If the index is not being used, you should drop it to improve insert
performance.