Skip to content

Commit 50b7dc4

Browse files
committed
perf: update queries to load up v2
Signed-off-by: Gustavo Inacio <[email protected]>
1 parent d70e7e2 commit 50b7dc4

4 files changed

+40
-53
lines changed

.sqlx/query-386e6b18da62b478ccdba5439490817f582abaec68e1ba01d55daee1e1edcbbd.json

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.sqlx/query-7124365390787371768fdb52259f8a9fd7f1a549ddd6410fa4359cacbea2ce6e.json

Lines changed: 0 additions & 26 deletions
This file was deleted.

.sqlx/query-7d2c582d3f92ccf179847bd01de43a328bea75b556032bfea57eb61b30e51f95.json renamed to .sqlx/query-7bf9c412120de537eecb8efb64da5b4ace9acc032be502cd1d9fc72c5b9ed50a.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/tap-agent/src/agent/sender_accounts_manager.rs

Lines changed: 12 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -622,17 +622,11 @@ impl State {
622622
FROM tap_horizon_receipts
623623
GROUP BY signer_address, allocation_id
624624
)
625-
SELECT DISTINCT
625+
SELECT
626626
signer_address,
627-
(
628-
SELECT ARRAY
629-
(
630-
SELECT DISTINCT allocation_id
631-
FROM grouped
632-
WHERE signer_address = top.signer_address
633-
)
634-
) AS allocation_ids
635-
FROM grouped AS top
627+
ARRAY_AGG(allocation_id) AS allocation_ids
628+
FROM grouped
629+
GROUP BY signer_address
636630
"#
637631
)
638632
.fetch_all(&self.pgpool)
@@ -668,18 +662,11 @@ impl State {
668662

669663
let nonfinal_ravs_sender_allocations_in_db = sqlx::query!(
670664
r#"
671-
SELECT DISTINCT
672-
sender_address,
673-
(
674-
SELECT ARRAY
675-
(
676-
SELECT DISTINCT allocation_id
677-
FROM tap_horizon_ravs
678-
WHERE sender_address = top.sender_address
679-
AND NOT last
680-
)
681-
) AS allocation_id
682-
FROM scalar_tap_ravs AS top
665+
SELECT
666+
payer,
667+
ARRAY_AGG(DISTINCT allocation_id) FILTER (WHERE NOT last) AS allocation_ids
668+
FROM tap_horizon_ravs
669+
GROUP BY payer
683670
"#
684671
)
685672
.fetch_all(&self.pgpool)
@@ -688,7 +675,7 @@ impl State {
688675

689676
for row in nonfinal_ravs_sender_allocations_in_db {
690677
let allocation_ids = row
691-
.allocation_id
678+
.allocation_ids
692679
.expect("all RAVs should have an allocation_id")
693680
.iter()
694681
.map(|allocation_id| {
@@ -698,8 +685,8 @@ impl State {
698685
)
699686
})
700687
.collect::<HashSet<_>>();
701-
let sender_id = Address::from_str(&row.sender_address)
702-
.expect("sender_address should be a valid address");
688+
let sender_id =
689+
Address::from_str(&row.payer).expect("sender_address should be a valid address");
703690

704691
// Accumulate allocations for the sender
705692
unfinalized_sender_allocations_map

0 commit comments

Comments
 (0)