finds.dev← search

// the find

plentz/lol_dba

★ 1,594 · Ruby · updated Mar 2026

lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.

lol_dba scans your Rails ActiveRecord models and tells you which foreign key and join columns are missing database indexes. It works by introspecting your model associations rather than your actual query patterns, so it catches the obvious structural gaps — the `_id` columns sitting there unindexed because you added a `belongs_to` and forgot the migration.

Covers the full Rails association surface: belongs_to, has_many :through, has_and_belongs_to_many — it handles the join table cases that people most often forget. The Appraisals test matrix going from Rails 3.2 through 8.x is genuinely thorough and shows the maintainer cares about not breaking existing users on upgrades. The SQL migration generator is a nice touch for teams that need to hand off DDL to a DBA rather than run Rails migrations directly. Zero configuration — drop it in the Gemfile, run one rake task, get actionable output.

It only knows about associations, not query patterns. Columns you filter or sort on frequently but aren't foreign keys won't show up, so you'll still miss real-world performance problems that can't be inferred from the model layer alone. The tool has no awareness of partial indexes, composite indexes, or whether an existing index already covers the column as a non-leading key — so its suggestions can be redundant or miss nuance. With 1594 stars and 70 forks after many years, this is a narrow utility that most teams use once during an audit and then forget, not something that stays in the toolchain. Last meaningful activity is sparse given the Rails 8 support was likely a compatibility bump, not feature work.

View on GitHub →

// want more like this?

Every week we dig through GitHub and send you a few repos picked for what you're working on, each with an honest take like this one. Free. See a real issue →

// similar repos

Search the finds →