How do you decide between optimizing joins and using window functions for performance?
Using the provided accounts and transactions tables, write a PostgreSQL query that produces the requested account totals and rankings, then explain the performance reasoning behind the approach.
account_id, institution_name, total_amount, and institution_rank.| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique account identifier |
| institution_name | VARCHAR(100) | Institution associated with the account |
| is_active | BOOLEAN | Whether the account is active |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| account_id | INT | Account associated with the transaction |
| transaction_date | DATE | Date the transaction occurred |
| amount | NUMERIC(12,2) | Transaction amount |
| transaction_status | VARCHAR(20) | Transaction processing status |