pluginagentmarketplace/custom-plugin-sql
Overview
This skill provides practical SQL query optimization and performance tuning guidance for relational databases. It focuses on analyzing execution plans, selecting and maintaining indexes, and applying query rewrite patterns to reduce latency and resource usage. The content spans common engines including PostgreSQL, MySQL, SQL Server, and Oracle, with cloud-specific considerations.
How this skill works
The skill inspects query execution plans, runtime statistics, and wait events to identify bottlenecks and expensive operations. It recommends index strategies (B-tree, covering, partial), join and aggregation rewrites, and configuration or hint-based adjustments for specific database engines. Actionable steps include profiling queries, validating changes with explain plans, and measuring before/after performance.
When to use it
- When queries exhibit high latency or unpredictable runtime
- To reduce CPU, I/O, or memory consumption on the database server
- Before adding hardware — to get more from existing resources
- When schema changes are planned and index impact must be evaluated
- When migrating or tuning workloads for cloud databases
Best practices
- Start with EXPLAIN/EXPLAIN ANALYZE and baseline metrics before making changes
- Prefer query rewrites and proper indexing before applying hints or engine-specific hacks
- Use covering and partial indexes to limit I/O for frequent access patterns
- Test performance changes in a staging environment with representative data
- Monitor index maintenance cost; avoid over-indexing that slows writes
Example use cases
- Convert correlated subqueries to joins or use window functions to improve performance
- Design a covering index to eliminate expensive table lookups for a reporting query
- Tune pagination by replacing OFFSET with keyset pagination for large result sets
- Profile and optimize bulk INSERT/UPDATE operations by batching and disabling nonessential indexes temporarily
- Apply PostgreSQL-specific configuration and vacuum strategies to reduce bloat and improve planner estimates
FAQ
Basic engine differences are covered, but core techniques like plan analysis and indexing apply across engines. Engine-specific advice is included for deeper tuning.
How do I validate that an optimization is safe?
Validate by comparing EXPLAIN ANALYZE outputs, running tests on staging with representative data, and ensuring query results remain identical before deploying to production.
11 skills
This skill analyzes SQL queries, suggests indexing and rewriting techniques to boost performance across databases.
This skill helps you implement database security covering access control, encryption, and audit logging to protect data and meet compliance.
This skill helps you manage MongoDB data efficiently by guiding document modeling, CRUD, indexing, and aggregation best practices.
This skill helps you perform exploratory data analysis and advanced SQL analytics to derive business insights from complex datasets.
This skill helps you master BI fundamentals including metric definitions, KPI calculations, dimensional modeling, and dashboard optimization for rapid data
This skill helps you design data warehouses using star schemas and slowly changing dimensions to improve query performance and accuracy.
This skill helps you implement ACID transactions, manage isolation levels, and handle concurrency in SQL backed applications.
This skill helps you master SQL fundamentals, enabling efficient data queries, updates, and design patterns across databases.
This skill helps you manage database schema changes safely with version control, migration tools, and zero-downtime deployment strategies.
This skill helps you leverage Redis data structures and commands for high-performance caching and real-time application capabilities.
This skill helps you administer and optimize MySQL databases, enabling efficient query tuning, replication setup, and reliable backups.