laravel-database-optimization
This skill provides 33 optimization rules across 9 categories for Laravel 13 applications, covering eager loading, indexing strategies, Redis caching, pagination, and transaction handling. Use it when writing Eloquent queries, diagnosing N+1 issues, configuring indexes, or debugging slow queries with Laravel Debugbar.
Laravel Database Optimization helps eliminate N+1 queries and boost Eloquent performance through eager loading, indexing, and caching strategies.
AI-generated summary based on this skill's SKILL.md
Decision gist · record as of 2026-05-16
Laravel Database Optimization helps eliminate N+1 queries and boost Eloquent performance through eager loading, indexing, and caching strategies. This skill provides 33 optimization rules across 9 categories for Laravel 13 applications, covering eager loading, indexing strategies, Redis caching, pagination, and transaction handling. Use it when writing Eloquent queries, diagnosing N+1 issues, configuring indexes, or debugging slow queries with Laravel Debugbar.
Use it when
- laravel-database-optimization covers database indexing best practices including single-column indexes.
- laravel-database-optimization teaches Redis caching integration for query results, including cache key strategies and invalidation patterns.
Verify before relying
Read SKILL.md below before installing (39 files). Open directory: indexed for reading, not audited.
Install
AsyrafHussin/agent-skills/laravel-database-optimization
Open directory. Skills are indexed for reading, not audited. Review a skill's body before installing it.
Frequently asked questions
AI-generated answers based on this skill's SKILL.md and metadata
How do I fix N+1 queries in Laravel?
laravel-database-optimization addresses N+1 query problems through eager loading techniques and relationship optimization. The skill provides rules for using Eloquent's `with()` and `load()` methods to fetch related data in single queries rather than iterating through results. It covers detecting N+1 issues with Laravel Debugbar, understanding lazy loading pitfalls, and implementing eager loading patterns across your application's query structure.
What indexing strategies does laravel-database-optimization recommend?
laravel-database-optimization covers database indexing best practices including single-column indexes, composite indexes for multi-column queries, and full-text search indexes. The skill provides guidance on index selection during migrations, query execution plan analysis, and identifying which columns benefit most from indexing. It addresses zero-downtime migration patterns for adding indexes to large tables without locking production data.
How can I implement Redis caching for Laravel queries?
laravel-database-optimization teaches Redis caching integration for query results, including cache key strategies and invalidation patterns. The skill covers cache-aside patterns, setting appropriate TTLs, and invalidating cached data when records change. It provides rules for deciding which queries benefit from caching and how to avoid stale data issues in your Laravel application.
How should I handle large datasets with pagination?
laravel-database-optimization covers pagination and memory-efficient processing for large datasets, including offset-based and cursor pagination approaches. The skill addresses chunking large tables with `chunk()` for batch processing, using `lazy()` collections, and selecting pagination strategies based on dataset size. It includes rules for preventing memory exhaustion when processing millions of records.
What tools help debug slow queries in Laravel?
laravel-database-optimization provides guidance on using Laravel Debugbar for query analysis, identifying slow queries, and diagnosing database performance issues. The skill covers query profiling, execution plan interpretation, and systematic debugging approaches. It includes techniques for measuring query impact and prioritizing optimization efforts across your Eloquent application.
What are the key optimization categories in this skill?
laravel-database-optimization organizes 33 optimization rules across 9 categories: eager loading, indexing strategies, Redis caching, pagination, transaction handling, query performance tuning, cursor pagination, cache invalidation, and lazy loading prevention. The skill applies to Laravel 13 applications and covers both query-level and database-level optimizations for comprehensive performance improvement.
SKILL.md
Rendered from the published skill. Quoted content, verbatim.
Laravel Database Optimization
Comprehensive database optimization guide for Laravel 13 applications. Contains 33 rules across 9 categories for writing performant database queries, proper indexing, efficient caching, naming conventions, and debugging slow queries in Laravel 13.
Metadata
- Version: 1.1.0
- Framework: Laravel 13.x
- PHP: 8.3+
When to Apply
Reference these guidelines when: - Writing Eloquent queries or using the query builder - Diagnosing and fixing N+1 query problems - Adding database indexes to migrations - Implementing Redis or cache-based optimizations - Paginating or processing large datasets - Wrapping operations in database transactions - Creating or modifying migrations for production databases - Debugging slow queries with EXPLAIN or
(truncated - see the full file via the links below)
File tree — 15 files
skills/laravel-database-optimization/AGENTS.md
skills/laravel-database-optimization/README.md
skills/laravel-database-optimization/SKILL.md
skills/laravel-database-optimization/metadata.json
skills/laravel-database-optimization/rules/_sections.md
skills/laravel-database-optimization/rules/_template.md
skills/laravel-database-optimization/rules/cache-invalidation.md
skills/laravel-database-optimization/rules/cache-remember.md
skills/laravel-database-optimization/rules/cache-tags.md
skills/laravel-database-optimization/rules/cache-ttl.md
skills/laravel-database-optimization/rules/data-avoid-unbounded.md
skills/laravel-database-optimization/rules/data-chunk-by-id.md
skills/laravel-database-optimization/rules/data-cursor-iteration.md
skills/laravel-database-optimization/rules/data-cursor-pagination.md
skills/laravel-database-optimization/rules/debug-explain-analyze.md
Let your AI agent find skills like this
Example. Real query, live index.
You found this page by searching. An agent finds it by wishing: SkillFed indexes 56,283 agent skills by what they can do, searchable in plain language.
wish › “Eliminate N+1 queries and optimize Eloquent query performance”
Give your agent the search over MCP, or paste the wish link into any chat. No install? Search from any chat →
Related skills
Laravel Best Practices is a comprehensive reference for building scalable Laravel 13 applications, covering 31 rules organized across architecture, Eloquent patterns, controllers, validation, security, performance, and API design. Use it when structuring applications, creating models and migrations, implementing form requests, or designing APIs. Includes essential patterns for service classes, repositories, form requests, and Eloquent models.
PHP Expert provides in-depth instruction on PHP 8+ language features including union types, named arguments, match expressions, attributes, and enums. Learn Laravel framework patterns, Composer dependency management, and object-oriented design principles for building robust applications.
This skill teaches proven patterns for writing efficient Eloquent queries, from eager loading relationships to selecting only needed columns and using query scopes. Learn how to prevent common performance pitfalls like N+1 queries, implement mass assignment protection, and leverage database-level operations for faster data manipulation.
Get expert guidance on Laravel 12.x application development, from foundational concepts like routing and database migrations to advanced patterns including Eloquent relationships, API design, and authentication with Sanctum. This skill covers the full development lifecycle—models, validation, queues, dependency injection, and best practices for building scalable web applications.
Master Laravel's architecture through proven patterns for building maintainable, production-ready applications. Covers controller and service layer design, Eloquent modeling with relationships and scopes, API resource structuring, and background job handling with queues and events.
This skill guides you through testing Laravel 13 applications with either Pest PHP 4 or PHPUnit 12, covering 24 rules across HTTP endpoints, model factories, database state verification, service mocking, and authentication patterns. It detects your project's testing framework automatically and provides syntax examples for both frameworks side-by-side, so you can write fast, readable tests regardless of which one you use.