Find non-sargable predicates

Proprietary

A comparison that wraps a column in a function, CAST, or arithmetic must evaluate the expression for every row, so an index on the bare column cannot be used for a range scan. Keeping the column alone on one side, e.g. amount > 100 - 1 rather than amount + 1 > 100, keeps the predicate index-eligible.

org.openrewrite.sql.antipattern.FindNonSargablePredicate

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.FindNonSargablePredicate

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