From bed81d785c50a1a056a409b8113eceb0c1d47bba Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 29 Jun 2021 09:22:38 +0000 Subject: an attempt to improve the query for direct messages on some systems with hopefully no bad side-effect for others --- Zotlabs/Widget/Messages.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Zotlabs/Widget/Messages.php') diff --git a/Zotlabs/Widget/Messages.php b/Zotlabs/Widget/Messages.php index 9679631c6..ed666bfaa 100644 --- a/Zotlabs/Widget/Messages.php +++ b/Zotlabs/Widget/Messages.php @@ -42,6 +42,7 @@ class Messages { $item_normal = item_normal(); $entries = []; $limit = 30; + $dummy_sql = ''; $offset = 0; if ($options['offset']) { @@ -53,6 +54,9 @@ class Messages { switch($options['type']) { case 'direct': $type_sql = ' AND item_private = 2 '; + // $dummy_order_sql has no other meaning but trick + // some mysql backends into using the right index. + $dummy_order_sql = ', received DESC '; break; case 'starred': $type_sql = ' AND item_starred = 1 '; @@ -66,7 +70,7 @@ class Messages { $type_sql AND item_thread_top = 1 $item_normal - ORDER BY created DESC + ORDER BY created DESC $dummy_order_sql LIMIT $limit OFFSET $offset", intval(local_channel()), dbescdate($loadtime) -- cgit v1.2.3