Find optional filters written as OR parameter IS NULL

Proprietary

The col = ? OR ? IS NULL pattern turns a filter on and off at runtime, so the planner must settle on one generic plan that works for every parameter combination instead of an index-driven plan for the filtered case. An IS NULL test on a column inside an OR is ordinary SQL and is not flagged.

org.openrewrite.sql.antipattern.FindOptionalParameterOr

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

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