Analyze and optimize database schemas, identify performance issues, and suggest improvements. Use when working with database structure, indexes, or query performance.
This skill helps you analyze database schemas, identify optimization opportunities, and understand table relationships.
User request: "Analyze the users table for optimization opportunities"
Approach:
Analysis Steps:
-- 1. Get table structure
DESCRIBE users;
-- 2. Check existing indexes
SHOW INDEX FROM users;
-- 3. Analyze table statistics
ANALYZE TABLE users;
Common Issues to Check:
User request: "Why are queries on the orders table slow?"
Approach:
Investigation Steps:
-- 1. Check table size
SELECT
table_name,
round(((data_length + index_length) / 1024 / 1024), 2) AS 'Size (MB)'
FROM information_schema.TABLES
WHERE table_name = 'orders';
-- 2. Identify slow queries
SHOW PROCESSLIST;
-- 3. Check query execution plan
EXPLAIN SELECT * FROM orders WHERE customer_id = 123;
Optimization Recommendations:
User request: "Review indexes on the products table"
Approach:
Review Process:
-- 1. Show all indexes
SHOW INDEX FROM products;
-- 2. Check index usage (MySQL 5.6+)
SELECT * FROM sys.schema_unused_indexes
WHERE object_schema = 'your_database'
AND object_name = 'products';
-- 3. Analyze query patterns
SELECT DISTINCT column_name
FROM information_schema.statistics
WHERE table_name = 'products';
Bundled resources in this skill package:
references/schema-patterns.sql - Common schema patternsscripts/analyze-table.php - Automated analysis scriptassets/optimization-checklist.md - Comprehensive checklistUse base directory from composer read-skill output to locate these files.