Quote:
|
Originally Posted by msateeshkumar
Hi
Below is the version of the DB2 used
DB2 code release "SQL08021" with level identifier "03020106".
A simple SQL statement which is performing a self join
Table  ample and below are the columns in the table
id integer
desc varchar(255)
No. of records 15000
Running the below query it takes 8-10minutes
select count(1) from sample a , sample b where a.id!=b.id and upper(a.desc) = upper(b.desc)
Table statistics reflect the current data and also a re-org is performed.
Are there any known performance issues with UDB when using upper/lower/translate.
Regards
Sateesh
|
How's this?
export to sample.ixf of ixf select id, desc from sample;
import from sample.ixf of ixf create into sampletemp;
update sampletemp set desc = upper(desc);
create index ixsample on sampletemp (desc asc);
select count(1) from sampletemp a , sampletemp b where a.id!=b.id and a.desc = b.desc;
Something like that... you might want to drop sampletemp afterwards.
I guarantee you that this will be a whole lot faster.
There are other ways: you might add an extra column, and perform the same trick on that. This eliminates the need for an extra table, and is easier to perform from an application.
Another way if achieving better performance is: look at the columns first. How many of them are uppercase already? You could perform a count on them, using the index, and a count on the rest, not using the index (because of the upper() function), and add the results. This could work if most of the rows have an upper case name. If everything is mixed case, then this will not work.
cheers,
Rob.