Laravel Performance Select Columns

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

noartem 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

noartem/laravel-vue-skills/tree/main/skills/laravel-performance-select-columns commit 1237affbf0

Frequently asked questions

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