]> git.mxchange.org Git - friendica.git/commitdiff
Optimized query for nodeinfo and admin user page
authorMichael Vogel <ike@pirati.ca>
Fri, 7 Oct 2016 21:07:21 +0000 (21:07 +0000)
committerMichael Vogel <ike@pirati.ca>
Fri, 7 Oct 2016 21:07:21 +0000 (21:07 +0000)
mod/admin.php
mod/nodeinfo.php

index b11faa39ac8a2ce921eabce19d0d67f711ba2d4a..c9ff23e2d84c9e1899c0031d25e8585e2f60e3d3 100644 (file)
@@ -1306,26 +1306,8 @@ function admin_page_users(&$a){
        $sql_order = "`".str_replace('.','`.`',$order)."`";
        $sql_order_direction = ($order_direction==="+")?"ASC":"DESC";
 
-/*     $users = q("SELECT `user`.* , `contact`.`name` , `contact`.`url` , `contact`.`micro`, `lastitem`.`lastitem_date`, `user`.`account_expired`
-                               FROM
-                                       (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
-                                       FROM `item`
-                                       WHERE `item`.`type` = 'wall'
-                                       GROUP BY `item`.`uid`) AS `lastitem`
-                                                RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`,
-                                          `contact`
-                               WHERE
-                                          `user`.`uid` = `contact`.`uid`
-                                               AND `user`.`verified` =1
-                                       AND `contact`.`self` =1
-                               ORDER BY $sql_order $sql_order_direction LIMIT %d, %d
-                               ",
-                               intval($a->pager['start']),
-                               intval($a->pager['itemspage'])
-                               );
-*/
        $users = q("SELECT `user`.*, `contact`.`name`, `contact`.`url`, `contact`.`micro`, `user`.`account_expired`,
-                               (SELECT `changed` FROM `item` WHERE `wall` AND `uid` = `user`.`uid` ORDER BY `changed` DESC LIMIT 1) AS `lastitem_date`
+                               (SELECT MAX(`changed`) FROM `item` FORCE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date`
                                FROM `user`
                                INNER JOIN `contact` ON `contact`.`uid` = `user`.`uid` AND `contact`.`self`
                                WHERE `user`.`verified`
index fae2b10522af3f13a97e24c4a1fb728abf2c6b69..585659e5cb4ebd3cb86c7e2988ea2a47af18e95f 100644 (file)
@@ -184,23 +184,9 @@ function nodeinfo_cron() {
                }
        }
         logger("cron_start");
-/*
-       $users = q("SELECT profile.*, `user`.`login_date`, `lastitem`.`lastitem_date`
-                       FROM (SELECT MAX(`item`.`changed`) as `lastitem_date`, `item`.`uid`
-                               FROM `item`
-                                       WHERE `item`.`type` = 'wall'
-                                               GROUP BY `item`.`uid`) AS `lastitem`
-                                               RIGHT OUTER JOIN `user` ON `user`.`uid` = `lastitem`.`uid`, `contact`, `profile`
-                                WHERE
-                                       `user`.`uid` = `contact`.`uid` AND `profile`.`uid` = `user`.`uid`
-                                       AND `profile`.`is-default` AND (`profile`.`publish` OR `profile`.`net-publish`)
-                                       AND `user`.`verified` AND `contact`.`self`
-                                       AND NOT `user`.`blocked`
-                                       AND NOT `user`.`account_removed`
-                                       AND NOT `user`.`account_expired`");
-*/
+
        $users = q("SELECT `user`.`uid`, `user`.`login_date`,
-                       (SELECT `changed` FROM `item` WHERE `wall` AND `uid` = `user`.`uid` ORDER BY `changed` DESC LIMIT 1) AS `lastitem_date`
+                       (SELECT MAX(`changed`) FROM `item` FORCE INDEX (`uid_wall_changed`) WHERE `wall` AND `uid` = `user`.`uid`) AS `lastitem_date`
                        FROM `user`
                        INNER JOIN `profile` ON `profile`.`uid` = `user`.`uid` AND `profile`.`is-default`
                        WHERE (`profile`.`publish` OR `profile`.`net-publish`) AND `user`.`verified`