ALERT: Some images may not load properly within the Knowledge Base Article. If you see a broken image, please right-click and select 'Open image in a new tab'. We apologize for this inconvenience.

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

book

Article ID: 15608

calendar_today

Updated On:

Products

Datacom DATACOM - AD CIS COMMON SERVICES FOR Z/OS 90S SERVICES DATABASE MANAGEMENT SOLUTIONS FOR DB2 FOR Z/OS COMMON PRODUCT SERVICES COMPONENT Common Services Datacom/AD CA ecoMeter Server Component FOC EASYTRIEVE REPORT GENERATOR FOR COMMON SERVICES INFOCAI MAINTENANCE IPC UNICENTER JCLCHECK COMMON COMPONENT Mainframe VM Product Manager CHORUS SOFTWARE MANAGER CA On Demand Portal CA Service Desk Manager - Unified Self Service PAM CLIENT FOR LINUX ON MAINFRAME MAINFRAME CONNECTOR FOR LINUX ON MAINFRAME GRAPHICAL MANAGEMENT INTERFACE WEB ADMINISTRATOR FOR TOP SECRET Xpertware

Issue/Introduction



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? 

Environment

Release: DATABB00200-14-Datacom/AD
Component:

Resolution

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.