Tell me how you approach optimizing a slow-running SQL query or join-heavy operation.
Using the provided PostgreSQL schema and sample data, describe your diagnosis and submit an optimized query that returns the required result set. Your answer should address execution plans, filtering, join behavior, aggregation, and indexing considerations.
Output
- One row per qualifying customer or unassigned order owner.
- Columns:
customer_name, order_count, and gross_value.
- Include completed January 2025 orders with positive gross value. Sort by
gross_value descending, then customer_name ascending.