Optimize Slow SQL Query Performance on Large Tables
I have a SQL query experiencing performance issues on a large table that needs optimization. Database Environment: - DBMS: [MySQL/PostgreSQL/SQL Server/etc] - Version: [version number] - Table size: [number] rows - Hardware: [basic specs if relevant] Current Query: [query] Table Schema: [CREATE TABLE statement or column definitions] Existing Indexes: [SHOW INDEX output or index list] Performance Metrics: - Current execution time: [seconds/minutes] - Rows examined: [number] - Query frequency: [how often it runs] Query Execution Plan: [EXPLAIN/EXPLAIN ANALYZE output] Business Requirements: - Expected response time: [target] - [any specific constraints] Please provide: 1. Analysis of current query performance bottlenecks 2. Optimized query with explanation of changes 3. Recommended indexes with justification 4. Alternative query approaches if applicable 5. Additional optimization strategies (partitioning, caching, etc.)