Prefer UNION over UNION ALL
WarningPerformance & Database#EC PREF_UNIONRemote Enabled
Overview
Prefer UNION over UNION ALL in SQL queries.
ATC Finding Message:
Prefer UNION over UNION ALL in SQL queries
Rationale
In ABAP SQL queries, prefer UNION to prevent duplicate record processing unless duplicates are explicitly intended and handled.
Non-Compliant
abap
SELECT a FROM ztab1 UNION ALL SELECT a FROM ztab2 INTO TABLE @lt_data.Compliant
abap
SELECT a FROM ztab1 UNION SELECT a FROM ztab2 INTO TABLE @lt_data.Suppression
To suppress findings for this rule, append the pseudo-comment to the statement:
abap
" Standard pseudo-comment:
... "#EC PREF_UNION
" SAP CI_ prefix format:
... "#EC CI_PREF_UNIONRelated Rules
- Prefer an Explicit JOIN Type —
#EC PREF_JOIN_TYPE - Prefer Strict SQL Host Variable Escaping —
#EC PREF_STRICT_SQL
Technical Details
- Native ATC Class:
ZCL_SKYLINT_PREF_UNION - Implementation File: zcl_skylint_pref_union.clas.abap