]> git.mxchange.org Git - friendica.git/commitdiff
Use NOT EXISTS to improve performance
authorHypolite Petovan <mrpetovan@gmail.com>
Wed, 28 Feb 2018 13:50:01 +0000 (08:50 -0500)
committerHypolite Petovan <mrpetovan@gmail.com>
Wed, 28 Feb 2018 13:50:26 +0000 (08:50 -0500)
src/Model/Profile.php

index c91fdc1a9e32d69f8d1d31e46f7898fe2a05e0b8..e493d82d53cfb36c4be9234bd093113211860909 100644 (file)
@@ -642,24 +642,26 @@ class Profile
                $classtoday = '';
 
                $s = dba::p(
-                       "SELECT `event`.*, `item`.`id`, `item`.`thr-parent`, `item`.`parent-uri`
+                       "SELECT *
                        FROM `event`
-                       LEFT JOIN `item`
-                               ON `item`.`uid` = `event`.`uid`
-                               AND `item`.`parent-uri` = `event`.`uri`
-                               AND `item`.`verb` = ?
-                               AND `item`.`visible`
-                               AND NOT `item`.`deleted`
                        WHERE `event`.`uid` = ?
                        AND  `event`.`type` != 'birthday'
                        AND  `event`.`start` < ?
                        AND  `event`.`start` >= ?
-                       AND `item`.`id` IS NULL
+                       AND NOT EXISTS (
+                               SELECT `id`
+                               FROM `item`
+                               WHERE `item`.`uid` = `event`.`uid`
+                               AND `item`.`parent-uri` = `event`.`uri`
+                               AND `item`.`verb` = ?
+                               AND `item`.`visible`
+                               AND NOT `item`.`deleted`
+                       )
                        ORDER BY  `event`.`start` ASC",
-                       ACTIVITY_ATTENDNO,
                        local_user(),
                        DateTimeFormat::utc('now + 7 days'),
-                       DateTimeFormat::utc('now - 1 days')
+                       DateTimeFormat::utc('now - 1 days'),
+                       ACTIVITY_ATTENDNO
                );
 
                $r = [];