From d88591c19ce1a4f69d32b924cbfd48ee4c942ea0 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Fri, 15 Mar 2013 14:11:58 -0400 Subject: [PATCH] cache: Fix the select_related() query name for sending_client. Previously we were calling select_related() on Message.client, which doesn't exist. It seems kinda poor that this doesn't raise an exception. I believe this issue was causing us to do very large numbers of database queries during get_updates calls during server restarts. (imported from commit b79bd698820fbd9dd82bd61fc175c32cd5ce6d05) --- zephyr/lib/cache_helpers.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/zephyr/lib/cache_helpers.py b/zephyr/lib/cache_helpers.py index 28e5aac7d0..cd9351dfac 100644 --- a/zephyr/lib/cache_helpers.py +++ b/zephyr/lib/cache_helpers.py @@ -13,12 +13,12 @@ def cache_save_message(message): @cache_with_key(message_cache_key) def cache_get_message(message_id): - return Message.objects.select_related("client", "sender").get(id=message_id) + return Message.objects.select_related("sending_client", "sender").get(id=message_id) # Called on Tornado startup to ensure our message cache isn't empty def populate_message_cache(): items_for_memcached = {} - for m in Message.objects.select_related("sender", "client").all().order_by( + for m in Message.objects.select_related("sending_client", "sender").all().order_by( "-id")[0:MESSAGE_CACHE_SIZE]: items_for_memcached[message_cache_key(m.id)] = (m,)