Zum Inhalt springen

Early Materialization (ARCH6056)

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Key ruby.orm.early-materialization · Severity warning · Category orm

Pulling the query result into an array and then filtering/sorting it in memory moves work that belongs in the database into the application. All rows are loaded needlessly.

active = User.all.select { |u| u.active? } # whole table pulled into memory
active = User.where(active: true) # filter applied in the DB

Push filtering/sorting/aggregation into the query chain (where, order) so the database does it, not memory.