From 200e18cd713fadcc24f5fe3b2c8db1f353f279a7 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Mon, 1 Aug 2011 16:59:43 -0400 Subject: [PATCH] reduce the number of queries required to get a notice's groups --- classes/Notice.php | 21 +++++---------------- 1 file changed, 5 insertions(+), 16 deletions(-) diff --git a/classes/Notice.php b/classes/Notice.php index 6540490b9a..d577408fef 100644 --- a/classes/Notice.php +++ b/classes/Notice.php @@ -1438,25 +1438,14 @@ class Notice extends Memcached_DataObject $gi->notice_id = $this->id; - if ($gi->find()) { - while ($gi->fetch()) { - $ids[] = $gi->group_id; - } - } - + $ids = $gi->fetchAll('group_id'); + self::cacheSet($keypart, implode(',', $ids)); } - $groups = array(); - - foreach ($ids as $id) { - $group = User_group::staticGet('id', $id); - if ($group) { - $groups[] = $group; - } - } - - return $groups; + $groups = User_group::multiGet('id', $ids); + + return $groups->fetchAll(); } /**