Order by before where (ARCH7076)
هذا المحتوى غير متوفر بلغتك بعد.
Key php.performance.orderby-before-where · Severity warning · Category performance
Sorting before filtering wastes work by ordering rows that are later discarded. Filter first, then sort the smaller result.
Incorrect
Section titled “Incorrect”<?php$result = collect($orders) ->sortBy('total') ->filter(fn ($o) => $o->status === 'paid') ->values();Correct
Section titled “Correct”<?php$result = collect($orders) ->filter(fn ($o) => $o->status === 'paid') ->sortBy('total') ->values();Move the sort after the filter step so only the smaller, needed set is ordered.