What steps would you take to ensure that your SQL queries are optimized for performance?
Using the provided PostgreSQL schema, write the query that should be optimized and describe the checks, indexing decisions, and validation steps you would use. The result must include active employees and their payroll totals for the first quarter of 2025.
employee_id, employee_name, total_paid, payment_count.total_paid descending, then employee_id ascending.| Column | Type | Description |
|---|---|---|
| employee_idPK | INT | Unique employee identifier |
| employee_name | VARCHAR(100) | Employee display name |
| status | VARCHAR(20) | Employment status |
| Column | Type | Description |
|---|---|---|
| payroll_idPK | INT | Unique payroll record identifier |
| employee_id | INT | Employee associated with the payroll record |
| paid_at | TIMESTAMP | Timestamp when the payroll payment was issued |
| amount | NUMERIC(12,2) | Payment amount |