From cdd5bd5615718094fba948e3d7d80a7082737be4 Mon Sep 17 00:00:00 2001 From: Hypolite Petovan Date: Sun, 17 Dec 2017 10:06:12 -0500 Subject: [PATCH] Improve networkpublic_timeline SQL performance - Use thread.iid for max_id and ordering --- include/api.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/include/api.php b/include/api.php index bedac23ac..b06629ff6 100644 --- a/include/api.php +++ b/include/api.php @@ -1691,7 +1691,7 @@ function api_statuses_networkpublic_timeline($type) $sql_extra = ''; if ($max_id > 0) { - $sql_extra = 'AND `item`.`id` <= ' . intval($max_id); + $sql_extra = 'AND `thread`.`iid` <= ' . intval($max_id); } $r = dba::p("SELECT " . item_fieldlists() . " @@ -1702,7 +1702,7 @@ function api_statuses_networkpublic_timeline($type) AND `verb` = ? AND `item`.`id` > ? $sql_extra - ORDER BY `thread`.`created` DESC + ORDER BY `thread`.`iid` DESC LIMIT " . intval($start) . ", " . intval($count), ACTIVITY_POST, $since_id