From d468a6e88b751828dfac5586929effdfccce55ad Mon Sep 17 00:00:00 2001 From: Andre Medeiros Date: Mon, 31 Oct 2022 21:30:04 -0400 Subject: [PATCH] change how we iterate over accounts --- internal/cmd/scheduler.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/internal/cmd/scheduler.go b/internal/cmd/scheduler.go index e7e8009..ed17ebc 100644 --- a/internal/cmd/scheduler.go +++ b/internal/cmd/scheduler.go @@ -456,7 +456,13 @@ func enqueueAccounts(ctx context.Context, logger *zap.Logger, statsd *statsd.Cli now := time.Now() - query := `SELECT reddit_account_id FROM accounts` + query := ` + SET work_mem TO '16MB'; + SELECT DISTINCT reddit_account_id FROM accounts + INNER JOIN devices_accounts ON devices_accounts.account_id = accounts.id + INNER JOIN devices ON devices.id = devices_accounts.device_id + WHERE grace_period_expires_at >= NOW(); + ` rows, err := pool.Query(ctx, query) if err != nil { logger.Error("failed to fetch accounts", zap.Error(err))