Find scalar subqueries in the SELECT list

Proprietary

A subquery used as an expression in the SELECT list may execute once per result row, turning a single scan into N+1 queries. A JOIN (or LATERAL join) produces the same values in one pass. Subqueries in WHERE, FROM, or JOIN conditions are not flagged.

org.openrewrite.sql.antipattern.FindScalarSubqueryInSelect

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

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