The ever-brilliant Phlip Plumlee with a way to lint SQL "pessimizations":
assert_efficient_sql - O'Reilly Ruby
To ensure your test cases call efficient MySQL…
# just wrap them in this block!
The assertion intercepts and copies out your MySQL SELECT statements, then calls EXPLAIN on each one, and inspects the results for common problems.
The goal is test cases that resist database pessimization, even as you change your data relations, to add new features. If you run your tests after every few changes, you can easily detect which change broke your database’s indices and relations.
This article is a reference for this assertion’s options.
Phlip is soliciting help with implementing this feature across more database engines.