| 1 | -- A wallet's entries in time order: statements, and balances before a date. |
| 2 | -- The amounts are in the index too, so sums never visit the table at all. |
| 3 | -- CONCURRENTLY builds it while the wallet keeps writing, and can't run in a |
| 4 | -- transaction: this file must hold this one statement, and nothing else. |
| 5 | CREATE INDEX CONCURRENTLY entries_account_id_created_at_idx |
| 6 | ON entries (account_id, created_at, id) INCLUDE (direction, amount); |