Commit c6a7c27
committed
Use unnest + LATERAL join to fetch latest balances
Replace the multi-placeholder IN tuple query with an unnest($1, $2) approach and a LATERAL subquery to select the most recent balance per (account_hash, asset_id). Build separate accountHashes and assetIds arrays as query params instead of expanding pair placeholders. This simplifies parameter handling and reliably returns the latest balance (ORDER BY _id DESC LIMIT 1) for each requested pair.1 parent 8928552 commit c6a7c27
1 file changed
+10
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
57 | | - | |
58 | | - | |
59 | | - | |
| 56 | + | |
| 57 | + | |
60 | 58 | | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
66 | 67 | | |
67 | 68 | | |
68 | 69 | | |
| |||
0 commit comments