Skip to content

Commit

Permalink
(NOBIDS) Flip day & validatorindex, for better index usage
Browse files Browse the repository at this point in the history
  • Loading branch information
recy21 committed Sep 4, 2023
1 parent 5e0bda2 commit fd56e35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cmd/misc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,7 @@ func CompareRewards(dayStart uint64, dayEnd uint64, validator uint64, bt *db.Big
err = db.ReaderDb.Get(&dbRewards, `
SELECT
COALESCE(cl_rewards_gwei, 0) AS cl_rewards_gwei
FROM validator_stats WHERE day = $1 and validatorindex = $2`, day, validator)
FROM validator_stats WHERE validatorindex = $2 AND day = $1`, day, validator)
if err != nil {
logrus.Fatalf("error getting cl_rewards_gwei from db: %v", err)
return
Expand Down
2 changes: 1 addition & 1 deletion db/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -3284,7 +3284,7 @@ func GetValidatorBalanceForDay(validators []uint64, day uint64, balance *uint64)
SELECT
COALESCE(SUM(end_balance), 0)
FROM validator_stats
WHERE day=$2 AND validatorindex = ANY($1)
WHERE validatorindex = ANY($1) AND day = $2
`, validatorsPQArray, day)
}

Expand Down

0 comments on commit fd56e35

Please sign in to comment.