Find LIKE patterns starting with a wildcard

Proprietary

A LIKE pattern whose first character is % or _ gives the database no prefix to seek in a B-tree index, so every row must be inspected. When a prefix search is not possible, a trigram or full-text index can serve the query instead. Parameter placeholders and patterns with only trailing wildcards are not flagged.

org.openrewrite.sql.antipattern.FindLeadingWildcardLike

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

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