How do you optimize query performance and manage storage costs in Amazon Redshift?
Using the supplied query history, table usage, and storage metadata, write a SQL query that identifies tables requiring optimization attention. Consider completed queries executed during January 2025 and include tables with no qualifying query activity.
Output
- One row per stored table with
table_name, query_count, total_runtime_ms, avg_runtime_ms, storage_mb, and optimization_priority.
- Classify priority as
HIGH, MEDIUM, or LOW using runtime, storage, dead-space, and unused-table signals.
- Order by total runtime descending, then storage size descending.