How do you optimize a query that is performing poorly on a large dataset in a banking environment?
You are given a query that returns slow results on a large transactional dataset. Improve it so it returns the same answer with better performance.
transaction_id, account_id, transaction_date, amount, region_name.transaction_date descending, then break ties by transaction_id descending.transaction_date is on or after DATE '2024-01-01'.status to equal POSTED and is_active to equal TRUE.| Column | Type | Description |
|---|---|---|
| transaction_idPK | BIGINT | Unique transaction identifier |
| account_id | BIGINT | Account associated with the transaction |
| transaction_date | DATE | Date the transaction was posted |
| amount | NUMERIC(12,2) | Transaction amount |
| status | VARCHAR(20) | Transaction status |
| Column | Type | Description |
|---|---|---|
| account_idPK | BIGINT | Unique account identifier |
| region_name | VARCHAR(50) | Account region |
| is_active | BOOLEAN | Whether the account is active |