Laravel Performance Select Columns

Select Only Needed Columns

ComeOnOliver Updated 61 repo stars

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

ComeOnOliver/skillshub/tree/main/skills/noartem/skills/laravel-performance-select-columns commit fc73bcebb4

Frequently asked questions

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