How do you optimize a slow-running SQL join on tables containing millions of enterprise transaction records?
Use the supplied transaction, account, and event tables. Return only positive transactions from the first quarter of 2025 whose latest event before April 1, 2025 is SETTLED.
account_id, account_name, transaction_month, settled_transaction_count, and total_settled_amountaccount_id, then transaction_month ascending| Column | Type | Description |
|---|---|---|
| account_idPK | INT | Unique enterprise account identifier |
| account_name | VARCHAR(120) | Enterprise account name |
| region | VARCHAR(40) | Account operating region |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique enterprise transaction identifier |
| account_id | INT | Owning enterprise account |
| transaction_date | DATE | Date on which the transaction occurred |
| amount | NUMERIC(18,2) | Transaction amount in the transaction currency |
| currency | VARCHAR(3) | ISO currency code |
| Column | Type | Description |
|---|---|---|
| event_idPK | INT | Unique transaction event identifier |
| transaction_id | INT | Transaction associated with the event |
| event_time | TIMESTAMP | Time when the event was recorded |
| event_status | VARCHAR(20) | Status recorded by the event |