diff options
author | friendica <info@friendica.com> | 2015-02-12 17:45:25 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2015-02-12 17:45:25 -0800 |
commit | da2349bb6a85d13f0aa29046bef3021cf0c884ba (patch) | |
tree | c6746dacc91a9f073bca67869074cc81825964df /mod | |
parent | 94a9aa9610647935a10ba6d4d8f70c955a9d7243 (diff) | |
download | volse-hubzilla-da2349bb6a85d13f0aa29046bef3021cf0c884ba.tar.gz volse-hubzilla-da2349bb6a85d13f0aa29046bef3021cf0c884ba.tar.bz2 volse-hubzilla-da2349bb6a85d13f0aa29046bef3021cf0c884ba.zip |
provide relief to sites that are severely impacted by the slow ITEM_UNSEEN searches. This does not incorporate any other flag optimisations as that will require a major DB update and possibly involve significant downtime. This is just to bite off a little chunk now and provide some much needed relief.
Diffstat (limited to 'mod')
-rw-r--r-- | mod/channel.php | 14 | ||||
-rw-r--r-- | mod/display.php | 5 | ||||
-rw-r--r-- | mod/home.php | 2 | ||||
-rw-r--r-- | mod/item.php | 6 | ||||
-rw-r--r-- | mod/manage.php | 4 | ||||
-rwxr-xr-x | mod/mood.php | 3 | ||||
-rw-r--r-- | mod/network.php | 7 | ||||
-rw-r--r-- | mod/photos.php | 6 | ||||
-rw-r--r-- | mod/ping.php | 19 |
9 files changed, 21 insertions, 45 deletions
diff --git a/mod/channel.php b/mod/channel.php index 1a471718d..788bacf70 100644 --- a/mod/channel.php +++ b/mod/channel.php @@ -147,23 +147,21 @@ function channel_content(&$a, $update = 0, $load = false) { if(($update) && (! $load)) { if ($mid) { $r = q("SELECT parent AS item_id from item where mid = '%s' and uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND (item_flags & %d) > 0 $sql_extra limit 1", + AND (item_flags & %d) > 0 AND item_unseen = 1 $sql_extra limit 1", dbesc($mid), intval($a->profile['profile_uid']), - intval(ITEM_WALL), - intval(ITEM_UNSEEN) + intval(ITEM_WALL) ); } else { $r = q("SELECT distinct parent AS `item_id`, created from item left join abook on item.author_xchan = abook.abook_xchan WHERE uid = %d AND item_restrict = 0 - AND (item_flags & %d) > 0 AND ( item_flags & %d ) > 0 + AND (item_flags & %d) > 0 AND item_unseen = 1 AND ((abook.abook_flags & %d) = 0 or abook.abook_flags is null) $sql_extra ORDER BY created DESC", intval($a->profile['profile_uid']), intval(ITEM_WALL), - intval(ITEM_UNSEEN), intval(ABOOK_FLAG_BLOCKED) ); } @@ -317,10 +315,8 @@ function channel_content(&$a, $update = 0, $load = false) { } if($is_owner && $update_unseen) { - $r = q("UPDATE item SET item_flags = (item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND (item_flags & %d) > 0 AND uid = %d $update_unseen", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 + AND (item_flags & %d) > 0 AND uid = %d $update_unseen", intval(ITEM_WALL), intval(local_channel()) ); diff --git a/mod/display.php b/mod/display.php index 467c476da..c2e5c2426 100644 --- a/mod/display.php +++ b/mod/display.php @@ -231,10 +231,7 @@ function display_content(&$a, $update = 0, $load = false) { } if($updateable) { - $x = q("UPDATE item SET item_flags = ( item_flags & ~%d ) - WHERE (item_flags & %d)>0 AND uid = %d and parent = %d ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $x = q("UPDATE item SET item_unseen = 0 WHERE item_unseen = 1 AND uid = %d and parent = %d ", intval(local_channel()), intval($r[0]['parent']) ); diff --git a/mod/home.php b/mod/home.php index 854e2df26..db4ae9c42 100644 --- a/mod/home.php +++ b/mod/home.php @@ -170,7 +170,7 @@ function home_content(&$a, $update = 0, $load = false) { $page_mode = 'list'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.item_unseen = 1 " : ''); if($update && $_SESSION['loadtime']) $simple_update .= " and item.changed > '" . datetime_convert('UTC','UTC',$_SESSION['loadtime']) . "' "; diff --git a/mod/item.php b/mod/item.php index ef0491895..99d28400b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -643,8 +643,7 @@ function item_post(&$a) { } } - if(local_channel() != $profile_uid) - $item_flags |= ITEM_UNSEEN; + $item_unseen = ((local_channel() != $profile_uid) ? 1 : 0); if($post_type === 'wall' || $post_type === 'wall-comment') $item_flags = $item_flags | ITEM_WALL; @@ -694,7 +693,7 @@ function item_post(&$a) { $datarray['aid'] = $channel['channel_account_id']; $datarray['uid'] = $profile_uid; - + $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; @@ -729,6 +728,7 @@ function item_post(&$a) { $datarray['term'] = $post_tags; $datarray['plink'] = $plink; $datarray['route'] = $route; + $datarray['item_unseen'] = $item_unseen; // preview mode - prepare the body for display and send it via json diff --git a/mod/manage.php b/mod/manage.php index 4a7b25068..cb46a1b76 100644 --- a/mod/manage.php +++ b/mod/manage.php @@ -57,9 +57,7 @@ function manage_content(&$a) { $c = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d )>0 and uid = %d", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d", intval($channels[$x]['channel_id']) ); diff --git a/mod/mood.php b/mod/mood.php index 4fe1ceb59..7663b2632 100755 --- a/mod/mood.php +++ b/mod/mood.php @@ -61,11 +61,10 @@ function mood_init(&$a) { $mid = item_message_id(); $action = sprintf( t('%1$s is %2$s','mood'), '[zrl=' . $poster['xchan_url'] . ']' . $poster['xchan_name'] . '[/zrl]' , $verbs[$verb]); - $item_flags = ITEM_WALL|ITEM_ORIGIN|ITEM_UNSEEN; + $item_flags = ITEM_WALL|ITEM_ORIGIN; if(! $parent_mid) $item_flags |= ITEM_THREAD_TOP; - $arr = array(); $arr['aid'] = get_account_id(); diff --git a/mod/network.php b/mod/network.php index 9a4707b4d..236d4c5e0 100644 --- a/mod/network.php +++ b/mod/network.php @@ -346,7 +346,7 @@ function network_content(&$a, $update = 0, $load = false) { else $page_mode = 'client'; - $simple_update = (($update) ? " and ( item.item_flags & " . intval(ITEM_UNSEEN) . " ) > 0 " : ''); + $simple_update = (($update) ? " and item.unseen = 1 " : ''); // This fixes a very subtle bug so I'd better explain it. You wake up in the morning or return after a day // or three and look at your matrix page - after opening up your browser. The first page loads just as it @@ -465,10 +465,7 @@ function network_content(&$a, $update = 0, $load = false) { } if(($update_unseen) && (! $firehose)) - $r = q("UPDATE item SET item_flags = ( item_flags & ~%d) - WHERE (item_flags & %d) > 0 AND uid = %d $update_unseen ", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("UPDATE item SET item_unseen = 0 where item_unseen = 1 AND uid = %d $update_unseen ", intval(local_channel()) ); diff --git a/mod/photos.php b/mod/photos.php index dbe165f60..33854dd76 100644 --- a/mod/photos.php +++ b/mod/photos.php @@ -877,11 +877,9 @@ function photos_content(&$a) { } if((local_channel()) && (local_channel() == $link_item['uid'])) { - q("UPDATE `item` SET item_flags = (item_flags & ~%d) WHERE parent = %d and uid = %d and (item_flags & %d)>0", - intval(ITEM_UNSEEN), + q("UPDATE `item` SET item_unseen = 0 WHERE item_unseen = 1 AND parent = %d AND uid = %d ", intval($link_item['parent']), - intval(local_channel()), - intval(ITEM_UNSEEN) + intval(local_channel()) ); } } diff --git a/mod/ping.php b/mod/ping.php index 6a89ad5cf..f49789be5 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -151,16 +151,12 @@ function ping_init(&$a) { if(x($_REQUEST, 'markRead') && local_channel()) { switch($_REQUEST['markRead']) { case 'network': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and uid = %d", intval(local_channel()) ); break; case 'home': - $r = q("update item set item_flags = ( item_flags & ~%d ) where (item_flags & %d) > 0 and (item_flags & %d) > 0 and uid = %d", - intval(ITEM_UNSEEN), - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where item_unseen = 1 and (item_flags & %d) > 0 and uid = %d", intval(ITEM_WALL), intval(local_channel()) ); @@ -190,8 +186,7 @@ function ping_init(&$a) { } if(x($_REQUEST, 'markItemRead') && local_channel()) { - $r = q("update item set item_flags = ( item_flags & ~%d ) where parent = %d and uid = %d", - intval(ITEM_UNSEEN), + $r = q("update item set item_unseen = 0 where parent = %d and uid = %d", intval($_REQUEST['markItemRead']), intval(local_channel()) ); @@ -278,10 +273,8 @@ function ping_init(&$a) { $result = array(); $r = q("SELECT * FROM item - WHERE item_restrict = %d and ( item_flags & %d ) > 0 and uid = %d + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d and author_xchan != '%s' ORDER BY created DESC", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_channel()), dbesc($ob_hash) ); @@ -386,10 +379,8 @@ function ping_init(&$a) { if($vnotify & (VNOTIFY_NETWORK|VNOTIFY_CHANNEL)) { $r = q("SELECT id, item_restrict, item_flags FROM item - WHERE (item_restrict = %d) and ( item_flags & %d ) > 0 and uid = %d + WHERE item_restrict = 0 and item_unseen = 1 and uid = %d and author_xchan != '%s'", - intval(ITEM_VISIBLE), - intval(ITEM_UNSEEN), intval(local_channel()), dbesc($ob_hash) ); |