Describe a time you had to optimize a slow-running SQL query or Spark job.
Using the provided PostgreSQL tables, rewrite the slow SQL pattern to return the required results efficiently. Explain how you would validate the improvement and identify useful indexes.
store_id, store_name, completed_transaction_count, and completed_revenue.store_id ascending.| Column | Type | Description |
|---|---|---|
| store_idPK | INT | Unique store identifier |
| store_name | VARCHAR(100) | Store display name |
| region | VARCHAR(50) | Geographic region |
| is_active | BOOLEAN | Whether the store is currently active |
| Column | Type | Description |
|---|---|---|
| transaction_idPK | INT | Unique transaction identifier |
| store_id | INT | Store associated with the transaction |
| transaction_date | DATE | Transaction date |
| status | VARCHAR(20) | Transaction processing status |
| amount | NUMERIC(10,2) | Transaction amount |