Laravel database optimization
Skill soden46/syarif-laravel-ai-skills/skills/laravel-database-optimization
Reusable Laravel AI skills for Codex, Claude Code, and other AI coding assistants
npx -y skills add soden46/syarif-laravel-ai-skills --skill laravel-database-optimizationAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- 22 days oldThe repository was created 22 days ago. New is not bad, but a brand new repository carrying a familiar-sounding name is the shape a typosquat arrives in, and there has been no time for anyone else to find a problem with it.
- 1 stars1 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
What its author says it does
Copied from the file, not written here
Optimize Laravel database work across N+1 queries, indexes, selective columns, caching, pagination, large data, locks, and migrations.
SKILL.md
2.7 KB, 503 tokens by cl100k_base, as published. Nobody here has run it
Laravel Database Optimization
Use this skill when improving query performance, reviewing migrations, debugging slow pages, or reducing memory and database load in Laravel apps.
This skill coordinates existing performance skills and adds an optimization workflow.
Priority Order
- Prove the bottleneck with logs, query inspection, profiling,
EXPLAIN, tests, or realistic data volume. - Fix query shape before adding infrastructure: eager loading, constraints, selective columns, aggregates, pagination, and bounded datasets.
- Add indexes that match actual filters, joins, sorts, and uniqueness rules.
- Cache only stable or expensive work with explicit invalidation.
- Review transaction scope, lock behavior, and retry strategy for write-heavy paths.
- Plan migrations with production data size and lock risk in mind.
Query Shape
- Prevent N+1 problems with intentional eager loading.
- Select only needed columns on hot paths, including constrained relationship columns.
- Use
withCount,withSum,exists, subqueries, or aggregates instead of loading full relations for summaries. - Avoid unbounded
all(), broadget(), and collection-side filtering on large tables. - Use cursor pagination or chunking for large ordered datasets and background processing.
Indexes And Migrations
- Add indexes for foreign keys, common filters, common sort paths, and composite access patterns.
- Match composite index order to the real query pattern.
- Avoid adding indexes speculatively without a query path that needs them.
- For production-scale tables, plan additive and reversible migrations; ask before destructive changes.
- When altering existing columns, preserve existing attributes required by the database platform.
Caching
- Cache expensive reads behind stable keys and short, intentional TTLs.
- Invalidate cache near the writes that change the underlying data.
- Use tags only when the configured cache store supports them.
- Do not cache user-specific or authorization-sensitive data without including the scope in the key.
Transactions And Locks
- Keep transactions short and free of slow external calls.
- Use row locks only around data that must remain consistent during the write.
- Use retry logic for known deadlock-prone flows.
- Dispatch jobs, events, notifications, and file cleanup after commit when correctness depends on committed data.
Related Skills
performance-eager-loadingperformance-select-columnsperformance-cachingdata-chunking-large-datasetsmigrations-and-factoriesdatabase-transactions
What ships with it
Read from the repository
Just SKILL.md. No reference files, no scripts.
Gives 0 of the 12 instructions most performance cost skills give in 503 tokens
Counted across 803 of the 1,058 authors here whose files we hold, read 2026-08-07
- Keep skill files under 500 lines or tokensin 82 of 803, across 16 files
- Use imperative form in instructionsin 80 of 803, across 9 files
- Draft assertions while test runs are in progressin 75 of 803, across 9 files
- Create two to three realistic test promptsin 74 of 803, across 9 files
- Write skill descriptions to be pushyin 72 of 803, across 7 files
- Save test cases to evals JSONin 72 of 803, across 6 files
- Ask questions about edge cases and input formatsin 72 of 803, across 7 files
- Save timing data immediately when runs completein 70 of 803, across 5 files
- Include all trigger conditions in the skill descriptionin 69 of 803, across 3 files
- Launch all test runs in a single turn or simultaneouslyin 69 of 803, across 3 files
- Capture intent before writing a skillin 67 of 803, across 1 file
- Import directly instead of barrel filesin 52 of 803, across 15 files
Said here and by no other author read
- fix query shape before adding infrastructure
- select only needed columns on hot paths
- use aggregates instead of loading full relations for summaries
- avoid unbounded queries on large tables
- avoid adding indexes speculatively
- cache expensive reads behind stable keys
Grouped from the skills themselves: near-identical wordings counted once, and counted by distinct author, so one author publishing three of these counts once. Length counted with cl100k_base; the agent that loads this file may tokenize it differently.