You should also BIND your program with the REOPT(VARS) parameter to allow DB2 to use an index on this predicate....
As long as at least one leading character is supplied DB2 can use an index. If, however, the leading character is unknown - that is, it is a percent sign (%) or underscore (_) - then DB2 would use an expensive table space scan. If you do not specify REOPT(VARS), then DB2 will not know what the variable contains and will likely resort to the scan for the query at BIND time. Of course, you could also use dynamic SQL to resolve this problem.
Dig Deeper on IBM DB2 management
Related Q&A from Craig S. Mullins
Our expert suggests that the best way to pass the SAP BW exam is to have hands-on job experience. But that's not all he has to say about ...continue reading
To export data from a DB2 table to a flat file, you need to run an export specifying the proper file format. The export utility exports data from a ...continue reading
Craig Mullins recommends two specific resources for learning how to create and support Binary Large Objects (BLOB) in DB2.continue reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.