Ir al contenido

Missing Index Candidate (ARCH6058)

Esta página aún no está disponible en tu idioma.

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.

# no index on the email column of the users table
User.where(email: params[:email]).first # full table scan
# Migration:
add_index :users, :email, unique: true
# the query now uses the index
User.where(email: params[:email]).first

Add add_index in a migration for frequently filtered columns to avoid full table scans.