Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Laravel Performance Eager Loading?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/comeonoliver-laravel-performance-eager-loading)
# Eager Loading and N+1 Prevention
## Load Relations Explicitly
```php
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):
```php
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