From 0b56c948b9d0ce0a3b069264d938d4e5b6fb2c4f Mon Sep 17 00:00:00 2001 From: Rohan Rangray <rrangray@ucsd.edu> Date: Wed, 3 Jun 2015 04:29:01 -0700 Subject: [PATCH] Prefetching users to optimize the query --- flashcards/management/commands/notifyusers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flashcards/management/commands/notifyusers.py b/flashcards/management/commands/notifyusers.py index 26ca296..7d8c436 100644 --- a/flashcards/management/commands/notifyusers.py +++ b/flashcards/management/commands/notifyusers.py @@ -8,7 +8,7 @@ class Command(BaseCommand): help = 'Notify the users if they have cards to be reviewed' def handle(self, *args, **options): - notify_list = UserFlashcard.objects.filter( + notify_list = UserFlashcard.objects.prefetch_related('user').filter( next_review__lte=Now() ).exclude( user__registration_id=None, -- 1.9.1