From cf3137449783bae7fa2bb2de47b64493d81dd510 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Mon, 3 Dec 2012 10:40:41 -0500 Subject: [PATCH] bulk_create_streams: Fix missing select_related(). bulk_create_streams was taking about 10 seconds to run with prod data; this should be a basically immediate operation. The cause was a missing select_related on one of the loops through all streams. (imported from commit 8b82f0c41facc3999bb699dbc350708ac69797e9) --- zephyr/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/zephyr/models.py b/zephyr/models.py index 87287c5805..d35df2fa67 100644 --- a/zephyr/models.py +++ b/zephyr/models.py @@ -321,7 +321,7 @@ def bulk_create_streams(realms, stream_list): batch_bulk_create(Stream, streams_to_create) recipients_to_create = [] - for stream in Stream.objects.all(): + for stream in Stream.objects.select_related().all(): if (stream.realm.domain, stream.name.lower()) not in existing_streams: recipients_to_create.append(Recipient(type_id=stream.id, type=Recipient.STREAM))