Find ORDER BY on a random function

Proprietary

Sorting by RAND(), RANDOM(), NEWID(), or DBMS_RANDOM computes a random value for every row and sorts the entire table just to keep a few rows. Sample by a key range or use the dialect's table sampling instead.

org.openrewrite.sql.antipattern.FindOrderByRandom

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

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