]> git.mxchange.org Git - friendica.git/commitdiff
Some optimized sql queries
authorMichael Vogel <icarus@dabo.de>
Mon, 6 Jun 2016 20:57:27 +0000 (22:57 +0200)
committerMichael Vogel <icarus@dabo.de>
Mon, 6 Jun 2016 20:57:27 +0000 (22:57 +0200)
boot.php
database.sql
include/dbstructure.php
include/group.php
mod/profile.php
update.php

index adfeeb415f554f68cb372f29f7dba096cc6d1d2a..99229972ebc11f32e1ef183833c8e9f7e1a178de 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM',     'Friendica');
 define ( 'FRIENDICA_CODENAME',     'Asparagus');
 define ( 'FRIENDICA_VERSION',      '3.5-dev' );
 define ( 'DFRN_PROTOCOL_VERSION',  '2.23'    );
-define ( 'DB_UPDATE_VERSION',      1195      );
+define ( 'DB_UPDATE_VERSION',      1196      );
 
 /**
  * @brief Constant with a HTML line break.
index 07fb65b96d9ebf59e68fa119e926d062c6605b13..8269a8bba086e80c68479eb3a439cdf4f43e6a53 100644 (file)
@@ -1,6 +1,6 @@
 -- ------------------------------------------
 -- Friendica 3.5-dev (Asparagus)
--- DB_UPDATE_VERSION 1195
+-- DB_UPDATE_VERSION 1196
 -- ------------------------------------------
 
 
@@ -511,7 +511,7 @@ CREATE TABLE IF NOT EXISTS `item` (
         INDEX `extid` (`extid`),
         INDEX `uid_id` (`uid`,`id`),
         INDEX `uid_created` (`uid`,`created`),
-        INDEX `uid_unseen` (`uid`,`unseen`),
+        INDEX `uid_unseen_contactid` (`uid`,`unseen`,`contact-id`),
         INDEX `uid_network_received` (`uid`,`network`,`received`),
         INDEX `uid_received` (`uid`,`received`),
         INDEX `uid_network_commented` (`uid`,`network`,`commented`),
index e6064b397148bf770c683c29ad6fce890b9eaf60..f89a3ff9268b60737edc5bcb4086e34478ed17ff 100644 (file)
@@ -847,7 +847,7 @@ function db_definition() {
                                        "extid" => array("extid"),
                                        "uid_id" => array("uid","id"),
                                        "uid_created" => array("uid","created"),
-                                       "uid_unseen" => array("uid","unseen"),
+                                       "uid_unseen_contactid" => array("uid","unseen","contact-id"),
                                        "uid_network_received" => array("uid","network","received"),
                                        "uid_received" => array("uid","received"),
                                        "uid_network_commented" => array("uid","network","commented"),
index 00b66ad58628f0db729447ed57987440b4a19e2f..53c0b78d841b5854f1eb08604a3c69aef0d2aad0 100644 (file)
@@ -366,7 +366,7 @@ function groups_containing($uid,$c) {
 function groups_count_unseen() {
 
        $r = q("SELECT `group`.`id`, `group`.`name`,
-                       (SELECT COUNT(*) FROM `item`
+                       (SELECT COUNT(*) FROM `item` FORCE INDEX (`uid_unseen_contactid`)
                                WHERE `uid` = %d AND `unseen` AND
                                        `contact-id` IN (SELECT `contact-id` FROM `group_member`
                                                                WHERE `group_member`.`gid` = `group`.`id` AND `group_member`.`uid` = %d)) AS `count`
index 26bd395230b8d937df35ceb1c5fcb10891116227..58e3a160721cc78014f7c1f3b49c6db09fb9c3ef 100644 (file)
@@ -284,7 +284,7 @@ function profile_content(&$a, $update = 0) {
 
                $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,
                        `thread`.`uid` AS `contact-uid`
-                       FROM `thread` INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
+                       FROM `thread` FORCE INDEX (`uid_created`) INNER JOIN `item` ON `item`.`id` = `thread`.`iid`
                        $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
                        AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
                        WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0
index b74edf7bbd98ce3acfb21df354bc5e64b7e8dab5..1189ac4a91b2c5e385e280f7a3908e95ee4e806d 100644 (file)
@@ -1,6 +1,6 @@
 <?php
 
-define('UPDATE_VERSION' , 1195);
+define('UPDATE_VERSION' , 1196);
 
 /**
  *