How would you optimize a slow-running query?
Using the provided PostgreSQL schema, write an optimized query that returns monthly metrics for active sites during January and February 2025. The query should avoid unnecessary rows and preserve sites with activity in either metric source.
Output
- One row per active site and month with activity
- Columns:
site_id, site_name, month, pageviews, and revenue
- Include only January and February 2025 activity, sort by
site_id, then month ascending, and return zero revenue when no non-null revenue exists