Database Query Optimization
Practical query tuning guide that uses EXPLAIN ANALYZE, indexing, and optimization checklists to cut response times.
- CCM score
- 39 of 100
- skills.sh installs
- 594
- GitHub stars
- 396
- last updated
- Aug 21, 2026
Own this skill? Claim it
What it does
- Covers query analysis with
EXPLAIN ANALYZE, indexing strategy, query rewrite techniques, and a pre-deployment optimization checklist - Reads plan output for sequential versus index scans, planned versus actual row counts, nested loops, and in-memory or disk sorts
- Provides four reference guides in a
references/directory alongside a quick-start example joining users to orders - Designed for diagnosing slow response times, high database CPU, performance regressions, and new feature rollouts
Install
$ npx -y skills add aj-geddes/useful-ai-prompts --skill database-query-optimization -yInstalls into .agents/skills for every agent it finds here, and .claude/skills for Claude Code.
Files
Database Query Optimization
Table of Contents
Overview
Slow database queries are a common performance bottleneck. Optimization through indexing, efficient queries, and caching dramatically improves application performance.
When to Use
- Slow response times
- High database CPU usage
- Performance regression
- New feature deployment
- Regular maintenance
Quick Start
Minimal working example:
-- Analyze query performance
EXPLAIN ANALYZE
SELECT users.id, users.name, COUNT(orders.id) as order_count
FROM users
LEFT JOIN orders ON users.id = orders.user_id
WHERE users.created_at > '2024-01-01'
GROUP BY users.id, users.name
ORDER BY order_count DESC;
-- Results show:
-- - Seq Scan (slow) vs Index Scan (fast)
-- - Rows: actual vs planned (high variance = bad)
-- - Execution time (milliseconds)
-- Key metrics:
-- - Sequential Scan: Full table read (slow)
-- - Index Scan: Uses index (fast)
-- - Nested Loop: Joins with loops
-- - Sort: In-memory or disk sort
Reference Guides
Details
- Repository
- github.com/aj-geddes/useful-ai-prompts
- Categories
- Databases, Debugging
- First seen
- Jun 3, 2026
More from aj-geddes/useful-ai-prompts
All 258- Database Backup Restore593
- Memory Leak Detection593
- Technical Roadmap Planning584
- Accessibility Testing583
- Push Notification Setup582
- Database Schema Documentation579
- Data Visualization576
- App Store Deployment571
- Mobile App Debugging571
- Security Audit Logging571
- Bundle Size Optimization569
- Process Mapping567
- Integration Testing564
- Oauth Implementation560
- Memory Optimization555
- Semantic Versioning555
- Caching Strategy552
- Web Performance Audit550
- Real Time Features549
- Browser Debugging547
- Mobile Offline Support547
- Design System Creation545
- Gcp Cloud Run545
- Causal Inference544
Similar to Database Query Optimization
More Databasessql-query-optimizationaj-geddes/useful-ai-prompts529 installsAnalyze and tune slow PostgreSQL and MySQL queries using plans, indexes, and rewrites.
sql-optimizationgithub/awesome-copilot16.4K installsUniversal SQL tuning guide covering query rewrites, indexing, pagination, and execution plan analysis across major engines.
database-performance-debuggingaj-geddes/useful-ai-prompts500 installsStructured debugging guide that finds slow queries, reviews execution plans, and tunes indexes across major databases.
sql-query-optimizerpatricio0312rev/skills298 installsCatalog guide for query tuning covering EXPLAIN analysis, index design, query rewrites, and benchmarking.
sql-optimization-patternswshobson/agents21K installsPractical SQL query tuning guide covering EXPLAIN analysis, index design, and common anti-pattern fixes.
sql-projeffallan/claude-skills7K installsExpert SQL help that optimizes slow queries, designs schemas, and migrates queries across dialects.