Find UNION where UNION ALL may suffice

Proprietary

Plain UNION de-duplicates the combined rows, forcing a sort or hash over the entire result even when the branches cannot overlap. UNION ALL skips that work. UNION inside a WITH item is not flagged because recursive CTEs rely on plain UNION semantics to terminate.

org.openrewrite.sql.antipattern.FindUnionInsteadOfUnionAll

Optional

markSourceBoolean

Whether to mark each occurrence in source, and apply the fix where the rule remediates. Defaults to true; set to false to leave source untouched and report only to the data table, as an analysis-only pipeline requires.

mod run . --recipe=org.openrewrite.sql.antipattern.FindUnionInsteadOfUnionAll

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.