laravel-performance-eager-loading
10
总安装量
10
周安装量
#29407
全站排名
安装命令
npx skills add https://github.com/noartem/laravel-vue-skills --skill laravel-performance-eager-loading
Agent 安装分布
codex
10
gemini-cli
8
opencode
8
amp
7
github-copilot
7
cursor
7
Skill 文档
Eager Loading and N+1 Prevention
Load Relations Explicitly
Post::with(['author', 'comments'])->paginate();
- Use
load()/loadMissing()after fetching models when needed - Select only required columns for both base query and relations
Guard Against Lazy Loading in Dev/Test
Add to a service provider (non-production):
Model::preventLazyLoading(! app()->isProduction());
Verify
- Use a query logger or debugbar to confirm relation queries are minimized
- Add tests that assert counts or avoid unexpected query spikes