Missing Index Candidate (ARCH6058)
Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.
Key ruby.orm.missing-index-candidate · Severity info · Category orm
A column repeatedly used in filter, order, or lookup predicates with no index forces full table scans. A DB index is suggested for such columns.
Incorrect
Section titled “Incorrect”# no index on the email column of the users tableUser.where(email: params[:email]).first # full table scanCorrect
Section titled “Correct”# Migration:add_index :users, :email, unique: true# the query now uses the indexUser.where(email: params[:email]).firstAdd add_index in a migration for frequently filtered columns to avoid full table scans.