Laravel:performance Select Columns

Select only required columns to reduce memory and transfer costs; apply to base queries and relations

jpcaparas 3307088 474 B Updated

File contents

Select Only Needed Columns

Reduce payloads by selecting exact fields:

User::select(['id', 'name'])->paginate();

Post::with(['author:id,name'])->select(['id','author_id','title'])->get();
  • Avoid *; keep DTOs/resources aligned with selected fields
  • Combine with eager loading to avoid N+1

jpcaparas/superpowers-laravel/tree/main/skills/performance-select-columns commit 33070888c4

Frequently asked questions

npx skillmds@latest add jpcaparas/laravel-performance-select-columns