Change to avoid a join in notice inbox

The join in notice_inbox is causing temp-table sorting on identi.ca,
so I'm trying a finer-tuned approach.
This commit is contained in:
Evan Prodromou
2009-04-28 13:07:05 -04:00
parent ce5b98ca01
commit c7105c2af1
3 changed files with 127 additions and 34 deletions

View File

@@ -451,34 +451,9 @@ class User extends Memcached_DataObject
} else if ($enabled === true ||
($enabled == 'transitional' && $this->inboxed == 1)) {
$cache = common_memcache();
$ids = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since);
if (!empty($cache)) {
# Get the notices out of the cache
$notices = $cache->get(common_cache_key($cachekey));
# On a cache hit, return a DB-object-like wrapper
if ($notices !== false) {
$wrapper = new ArrayWrapper(array_slice($notices, $offset, $limit));
return $wrapper;
}
}
$inbox = Notice_inbox::stream($this->id, $offset, $limit, $since_id, $before_id, $since);
$ids = array();
while ($inbox->fetch()) {
$ids[] = $inbox->notice_id;
}
$inbox->free();
unset($inbox);
return Notice::getStreamByIds($ids, 'user:notices_with_friends:' . $this->id);
return Notice::getStreamByIds($ids);
}
}