
Query Optimization
- 1 installs
- 27 repo stars
- Updated April 25, 2026
- girijashankarj/cursor-handbook
Workflow to identify slow database queries, analyze the query plan with EXPLAIN ANALYZE, and fix missing indexes or inefficient joins.
About
Guides identifying and fixing slow database queries using query-plan analysis. A developer uses it when a query is slow or database performance needs improvement.
- Runs EXPLAIN ANALYZE to inspect the query plan
- Finds sequential scans and missing indexes
Query Optimization by the numbers
- 1 all-time installs (skills.sh)
- Ranked #770 of 911 Databases skills by installs in the Skillselion catalog
- Data as of Jul 22, 2026 (Skillselion catalog sync)
npx skills add https://github.com/girijashankarj/cursor-handbook --skill query-optimizationAdd your badge
Show developers this skill is listed on Skillselion. Paste this into your README.
| Installs | 1 |
|---|---|
| repo stars | ★ 27 |
| Last updated | April 25, 2026 |
| Repository | girijashankarj/cursor-handbook ↗ |
What it does
Workflow to identify slow database queries, analyze the query plan with EXPLAIN ANALYZE, and fix missing indexes or inefficient joins.
Files
Skill: Optimize Database Query
Trigger
When a query is slow or user asks to optimize database performance.
Steps
Step 1: Identify Slow Query
- [ ] Get the query text
- [ ] Measure current execution time
- [ ] Check query frequency (how often it runs)
Step 2: Analyze Query Plan
- [ ] Run EXPLAIN ANALYZE on the query
- [ ] Identify sequential scans on large tables
- [ ] Check for missing indexes
- [ ] Look for unnecessary joins or subqueries
- [ ] Check sort operations (external sorts)
Step 3: Optimize
Common optimizations:
- [ ] Add missing indexes
- [ ] Rewrite subqueries as JOINs
- [ ] Add WHERE clause filters to reduce data
- [ ] Use cursor-based pagination instead of OFFSET
- [ ] Add partial indexes for filtered queries
- [ ] Denormalize if read performance is critical
Step 4: Benchmark
- [ ] Run optimized query with EXPLAIN ANALYZE
- [ ] Compare before/after execution times
- [ ] Test with production-like data volume
- [ ] Verify results are identical
Step 5: Implement
- [ ] Update query in code
- [ ] Create migration for new indexes
- [ ] Add monitoring for the query
- [ ] Update any affected tests
Completion
Query optimized with measurable improvement and monitoring in place.