diff options
author | friendica <info@friendica.com> | 2012-01-01 23:07:53 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2012-01-01 23:07:53 -0800 |
commit | fb3a0baa786926b12b35525cb2a08c3dedb58e18 (patch) | |
tree | 478cd66796196f2be748909659a3ab0c72f1690a /mod/network.php | |
parent | 0cd1f5eae4dc7d82603f8b7cf0d9b50c34b04f96 (diff) | |
download | volse-hubzilla-fb3a0baa786926b12b35525cb2a08c3dedb58e18.tar.gz volse-hubzilla-fb3a0baa786926b12b35525cb2a08c3dedb58e18.tar.bz2 volse-hubzilla-fb3a0baa786926b12b35525cb2a08c3dedb58e18.zip |
long running query on network page - optimise out the double sub-select
Diffstat (limited to 'mod/network.php')
-rw-r--r-- | mod/network.php | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/mod/network.php b/mod/network.php index 8f65475db..a8f4f72ec 100644 --- a/mod/network.php +++ b/mod/network.php @@ -276,7 +276,9 @@ function network_content(&$a, $update = 0) { if($bmark) $star_sql .= " AND `bookmark` = 1 "; - $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql ) "; + $update_sql = ((($update) && (! $nouveau)) ? " and unseen = 1 " : ''); + + $sql_extra = " AND `item`.`parent` IN ( SELECT `parent` FROM `item` WHERE `id` = `parent` $star_sql $update_sql ) "; if($group) { $r = q("SELECT `name`, `id` FROM `group` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -300,7 +302,7 @@ function network_content(&$a, $update = 0) { info( t('Group is empty')); } - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $star_sql AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $star_sql $update_sql AND ( `contact-id` IN ( $contact_str ) OR `allow_gid` REGEXP '<" . intval($group) . ">' )) "; $o = '<h2>' . t('Group: ') . $r[0]['name'] . '</h2>' . $o; } elseif($cid) { @@ -310,7 +312,7 @@ function network_content(&$a, $update = 0) { intval($cid) ); if(count($r)) { - $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $star_sql AND `contact-id` = " . intval($cid) . " ) "; + $sql_extra = " AND `item`.`parent` IN ( SELECT DISTINCT(`parent`) FROM `item` WHERE 1 $star_sql $update_sql AND `contact-id` = " . intval($cid) . " ) "; $o = '<h2>' . t('Contact: ') . $r[0]['name'] . '</h2>' . $o; if($r[0]['network'] === NETWORK_OSTATUS && $r[0]['writable'] && (! get_pconfig(local_user(),'system','nowarn_insecure'))) { notice( t('Private messages to this person are at risk of public disclosure.') . EOL); @@ -430,7 +432,6 @@ function network_content(&$a, $update = 0) { $r = q("SELECT distinct(`parent`) AS `item_id`, `contact`.`uid` AS `contact_uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - and `item`.`parent` in ( select parent from item where unseen = 1 ) AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval(local_user()) |