How do I increase efficiency of a SQL SELECT using the LIKE operator in a WHERE clause?

Document ID : KB000015608
Last Modified Date : 14/02/2018
Show Technical Document Details
Question:

I have a program accessing Datacom tables using the SQL command below but it is taking a long time to run.

SELECT ID, NAME, CODE 
FROM VENDOR
WHERE  NAME LIKE '%PROCESS%%%%%%%%%%%%%%';

How do I increase efficiency of this SQL SELECT using the LIKE operator?

Will creating a VIEW help? 

Answer:

Creating a view will not improve performance of the SQL SELECT.

The way to improve performance is to add a KEY for the column referred to in the in LIKE operator in the WHERE clause. In the example above, add a KEY on the NAME column.