Skip to content

Commit 54c2920

Browse files
committed
remove cross join
1 parent 9c2d801 commit 54c2920

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

pkg/rewards/2_goldStakerRewardAmounts.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,12 @@ latest_operator_avs_snapshots AS (
1818
ap.reward_hash,
1919
ap.snapshot as reward_snapshot,
2020
ap.avs,
21-
MAX(oar.snapshot) as latest_operator_snapshot
21+
(SELECT MAX(oar.snapshot)
22+
FROM operator_avs_registration_snapshots oar
23+
WHERE oar.avs = ap.avs
24+
AND oar.snapshot <= ap.snapshot) as latest_operator_snapshot
2225
FROM {{.activeRewardsTable}} ap
23-
CROSS JOIN (SELECT DISTINCT snapshot, avs FROM operator_avs_registration_snapshots) oar
2426
WHERE ap.reward_type = 'avs'
25-
AND oar.avs = ap.avs
26-
AND oar.snapshot <= ap.snapshot
27-
GROUP BY ap.reward_hash, ap.snapshot, ap.avs
2827
),
2928
reward_snapshot_operators as (
3029
SELECT

pkg/rewards/9_goldStakerODRewardAmounts.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,12 +55,11 @@ latest_staker_delegation_snapshots AS (
5555
ors.reward_hash,
5656
ors.snapshot as reward_snapshot,
5757
ors.operator,
58-
MAX(sds.snapshot) as latest_delegation_snapshot
58+
(SELECT MAX(sds.snapshot)
59+
FROM staker_delegation_snapshots sds
60+
WHERE sds.operator = ors.operator
61+
AND sds.snapshot <= ors.snapshot) as latest_delegation_snapshot
5962
FROM staker_splits ors
60-
CROSS JOIN (SELECT DISTINCT snapshot, operator FROM staker_delegation_snapshots) sds
61-
WHERE sds.operator = ors.operator
62-
AND sds.snapshot <= ors.snapshot
63-
GROUP BY ors.reward_hash, ors.snapshot, ors.operator
6463
),
6564
-- Get the stakers that were delegated to the operator for the snapshot
6665
staker_delegated_operators AS (

0 commit comments

Comments
 (0)