Update sorting for group inbox timelines; adds group_inbox_group_id_created_notice_id_idx index to group_inbox table

This commit is contained in:
Brion Vibber 2010-12-17 14:51:37 -08:00
parent 3ddfa4de93
commit 66474586af
3 changed files with 10 additions and 9 deletions

View File

@ -100,15 +100,10 @@ class User_group extends Memcached_DataObject
$inbox->selectAdd(); $inbox->selectAdd();
$inbox->selectAdd('notice_id'); $inbox->selectAdd('notice_id');
if ($since_id != 0) { Notice::addWhereSinceId($inbox, $since_id, 'notice_id');
$inbox->whereAdd('notice_id > ' . $since_id); Notice::addWhereMaxId($inbox, $max_id, 'notice_id');
}
if ($max_id != 0) { $inbox->orderBy('created DESC, notice_id DESC');
$inbox->whereAdd('notice_id <= ' . $max_id);
}
$inbox->orderBy('notice_id DESC');
if (!is_null($offset)) { if (!is_null($offset)) {
$inbox->limit($offset, $limit); $inbox->limit($offset, $limit);

View File

@ -8,3 +8,6 @@ alter table notice_tag add index notice_tag_tag_created_notice_id_idx (tag, crea
-- Needed for sorting reply/mentions timelines -- Needed for sorting reply/mentions timelines
alter table reply add index reply_profile_id_modified_notice_id_idx (profile_id, modified, notice_id); alter table reply add index reply_profile_id_modified_notice_id_idx (profile_id, modified, notice_id);
-- Needed for sorting group messages by timestamp
alter table group_inbox add index group_inbox_group_id_created_notice_id_idx (group_id, created, notice_id);

View File

@ -480,7 +480,10 @@ create table group_inbox (
constraint primary key (group_id, notice_id), constraint primary key (group_id, notice_id),
index group_inbox_created_idx (created), index group_inbox_created_idx (created),
index group_inbox_notice_id_idx (notice_id) index group_inbox_notice_id_idx (notice_id),
-- Needed for sorting group messages by timestamp
index group_inbox_group_id_created_notice_id_idx (group_id, created, notice_id)
) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin; ) ENGINE=InnoDB CHARACTER SET utf8 COLLATE utf8_bin;