Early Materialization (ARCH7056)
هذا المحتوى غير متوفر بلغتك بعد.
Key php.orm.early-materialization · Severity warning · Category orm
Filtering or sorting in PHP memory after pulling a query into an array moves work that belongs in the database into the application. Unneeded rows are fetched over the wire and memory balloons.
Incorrect
Section titled “Incorrect”<?php$users = User::all()->toArray();$active = array_filter($users, fn($u) => $u['active']); // in-memory filterCorrect
Section titled “Correct”<?php$active = User::where('active', true)->get(); // filter in the DBPush filtering, ordering, and aggregation into the query’s WHERE/ORDER BY.