Laravel:performance Select Columns

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

jpcaparas Updated 157 repo stars
image

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 commit 33070888c4

Frequently asked questions

npx get-skill add jpcaparas/laravel-performance-select-columns