Skip to content

Avoid Leading Wildcards in LIKE Conditions ​

WarningPerformance & Database#EC NO_LEAD_WILDCARDRemote Enabled

Overview ​

Avoid leading wildcard (% or +) in LIKE conditions.

ATC Finding Message: Avoid leading wildcard (% or +) in LIKE; prevents index usage causing full scan

Rationale ​

Using a leading wildcard (% or +) in a LIKE condition (e.g. LIKE '%value') prevents the database optimizer from using B-tree and column indexes, resulting in full index scans or table scans.

Standard: Avoid leading wildcards in search patterns. If substring search is needed on large tables, consider SAP HANA full-text indexes or fuzzy search.

Non-Compliant ​

abap
" Leading wildcard prevents index utilization
SELECT * FROM t000 WHERE mandt LIKE '%00' INTO TABLE @DATA(lt_data).

Compliant ​

abap
" Prefix match utilizes index
SELECT * FROM t000 WHERE mandt LIKE '100%' INTO TABLE @DATA(lt_data).

Suppression ​

To suppress findings for this rule, append the pseudo-comment to the statement:

abap
" Standard pseudo-comment:
... "#EC NO_LEAD_WILDCARD

" SAP CI_ prefix format:
... "#EC CI_NO_LEAD_WILDCARD

Technical Details ​

Released under the MIT License.