db-management
db-management equips database developers and DBAs with targeted tools for query optimization. Use analyze_query for AI-driven performance analysis, root causes, and fix recommendations; detect_slow_queries to identify slow runners in PostgreSQL, MySQL, or MongoDB; and suggest_indexes to spot missing indexes from WHERE, JOIN, and ORDER BY clauses. Get execution plans via explain_query and table health stats with get_table_stats.
Overview
The db-management MCP server provides specialized tools for diagnosing and optimizing database queries across PostgreSQL, MySQL, and MongoDB. It connects directly to your database to analyze execution plans, detect slow queries, and suggest indexes, enabling precise performance tuning without manual deep dives. Database teams use it to reduce query times and resource usage through data-driven insights.
Key Capabilities
- analyze_query: Analyzes a raw SQL query's execution plan to pinpoint performance issues, root causes, severity levels, and targeted fixes with estimated improvements.
- detect_slow_queries: Scans live or historical queries using database-specific stats (pg_stat_statements for PostgreSQL, performance_schema for MySQL, currentOp for MongoDB) to identify current or past slow performers.
- suggest_indexes: Parses WHERE, JOIN, and ORDER BY clauses in a query, compares against existing indexes, and recommends missing ones for better performance.
- explain_query: Executes EXPLAIN (or EXPLAIN ANALYZE with verbose flag) on a query, delivering a readable breakdown of the plan, bottlenecks like sequential scans, and improvement suggestions.
- get_table_stats: Fetches table metrics including size, row count, index size, health score, plus PostgreSQL-specific details like last vacuum time and sequential scans.
- compare_queries: Contrasts execution plans of two query versions side-by-side, uses AI to declare a winner, and explains why with actionable recommendations.
Use Cases
Run detect_slow_queries on a production PostgreSQL instance to list top slow queries from pg_stat_statements, then apply analyze_query to refactor the worst offender. Before deploying a new report query, use suggest_indexes to check for missing indexes on JOIN columns and avoid full table scans. Compare an original SQL query against a rewritten version with compare_queries to validate which runs faster and why during code reviews. Check table bloat with get_table_stats on high-traffic tables to schedule vacuums based on sequential scan counts.
Who This Is For
Database administrators, backend developers, and data engineers who write and optimize SQL queries. Requires familiarity with SQL and basic database concepts like indexes and execution plans; ideal for intermediate users managing PostgreSQL, MySQL, or MongoDB workloads.