---- Start
We have introducedAvoid using functions in the WHERE clause of SQL statements.This will invalidate the index on this field and affect the performance of SQL statements. Based on the same principle, we should also avoid usingLike. Consider the following:
Create Table user <br/> (<br/> name varchar (20) not null, --- name <br/> mynumber varchar (18) --- ID card number <br/> );
What should I do if I ask you to check the ID card number starting with 2102 (from Dalian? We naturally write this:
Select * from user where mynumber like '123 ';
The preceding statements are completely correct, but the performance is poor. How can this problem be solved? The answer is to convert it into a range scan, as shown below:
Select * from user where mynumber> = '000000' and mynumber <'000000 ';
--- For more information, see:DB2 SQL
----Statement: indicate the source for reprinting.
---- Last updated on 2009.9.24
---- Written by shangbo on 2009.9.24
---- End