Ultimate access to all questions.
Given a dataset stored in Amazon Redshift, you need to perform a complex SQL query involving multiple JOINs and aggregations. The query is as follows: SELECT department, AVG(salary) AS avg_salary FROM employees JOIN departments ON employees.dept_id = departments.id GROUP BY department ORDER BY avg_salary DESC. What are the potential performance implications of this query and how might you optimize it?