Skip to content

Select Star Over-Fetch (ARCH7066)

Key php.orm.select-star-over-fetch · Severity info · Category orm

Fetching a full entity/all columns when only a few fields are used downstream needlessly inflates row width and serialization cost. A projection (select, pluck) fetches only the needed fields.

<?php
$names = User::all()->map(fn($u) => $u->name); // all columns fetched
<?php
$names = User::pluck('name'); // only the name column

Use a projection (select/pluck) that selects only the fields you use.