distinct is needed or it can heavily impact pagination in certain situations (5 per page instead of 20). Add ordering to the select clause to mitigate errors in postgres and add item_thread_top = 1 for slightly better performance.
This commit is contained in:
parent
a42ff1e6d4
commit
3d3e7bafd5
@ -282,13 +282,13 @@ class Channel extends \Zotlabs\Web\Controller {
|
||||
}
|
||||
}
|
||||
else {
|
||||
$r = q("SELECT item.parent AS item_id FROM item
|
||||
$r = q("SELECT DISTINCT item.parent AS item_id, $ordering FROM item
|
||||
left join abook on ( item.author_xchan = abook.abook_xchan $abook_uids )
|
||||
WHERE true and item.uid = %d $item_normal
|
||||
AND (abook.abook_blocked = 0 or abook.abook_flags is null)
|
||||
AND item.item_wall = 1
|
||||
AND item.item_wall = 1 AND item.item_thread_top = 1
|
||||
$sql_extra $sql_extra2
|
||||
ORDER BY $ordering DESC, id $pager_sql ",
|
||||
ORDER BY $ordering DESC $pager_sql ",
|
||||
intval(\App::$profile['profile_uid'])
|
||||
);
|
||||
}
|
||||
|
Reference in New Issue
Block a user