Some optimized sql queries

This commit is contained in:
Michael Vogel 2016-06-06 22:57:27 +02:00
parent db44ea0482
commit fc66a86dc5
6 changed files with 7 additions and 7 deletions

View file

@ -38,7 +38,7 @@ define ( 'FRIENDICA_PLATFORM', 'Friendica');
define ( 'FRIENDICA_CODENAME', 'Asparagus'); define ( 'FRIENDICA_CODENAME', 'Asparagus');
define ( 'FRIENDICA_VERSION', '3.5-dev' ); define ( 'FRIENDICA_VERSION', '3.5-dev' );
define ( 'DFRN_PROTOCOL_VERSION', '2.23' ); define ( 'DFRN_PROTOCOL_VERSION', '2.23' );
define ( 'DB_UPDATE_VERSION', 1195 ); define ( 'DB_UPDATE_VERSION', 1196 );
/** /**
* @brief Constant with a HTML line break. * @brief Constant with a HTML line break.

View file

@ -1,6 +1,6 @@
-- ------------------------------------------ -- ------------------------------------------
-- Friendica 3.5-dev (Asparagus) -- 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 `extid` (`extid`),
INDEX `uid_id` (`uid`,`id`), INDEX `uid_id` (`uid`,`id`),
INDEX `uid_created` (`uid`,`created`), 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_network_received` (`uid`,`network`,`received`),
INDEX `uid_received` (`uid`,`received`), INDEX `uid_received` (`uid`,`received`),
INDEX `uid_network_commented` (`uid`,`network`,`commented`), INDEX `uid_network_commented` (`uid`,`network`,`commented`),

View file

@ -847,7 +847,7 @@ function db_definition() {
"extid" => array("extid"), "extid" => array("extid"),
"uid_id" => array("uid","id"), "uid_id" => array("uid","id"),
"uid_created" => array("uid","created"), "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_network_received" => array("uid","network","received"),
"uid_received" => array("uid","received"), "uid_received" => array("uid","received"),
"uid_network_commented" => array("uid","network","commented"), "uid_network_commented" => array("uid","network","commented"),

View file

@ -366,7 +366,7 @@ function groups_containing($uid,$c) {
function groups_count_unseen() { function groups_count_unseen() {
$r = q("SELECT `group`.`id`, `group`.`name`, $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 WHERE `uid` = %d AND `unseen` AND
`contact-id` IN (SELECT `contact-id` FROM `group_member` `contact-id` IN (SELECT `contact-id` FROM `group_member`
WHERE `group_member`.`gid` = `group`.`id` AND `group_member`.`uid` = %d)) AS `count` WHERE `group_member`.`gid` = `group`.`id` AND `group_member`.`uid` = %d)) AS `count`

View file

@ -284,7 +284,7 @@ function profile_content(&$a, $update = 0) {
$r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`, $r = q("SELECT `thread`.`iid` AS `item_id`, `thread`.`network` AS `item_network`,
`thread`.`uid` AS `contact-uid` `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` $sql_post_table INNER JOIN `contact` ON `contact`.`id` = `thread`.`contact-id`
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0 WHERE `thread`.`uid` = %d AND `thread`.`visible` = 1 AND `thread`.`deleted` = 0

View file

@ -1,6 +1,6 @@
<?php <?php
define('UPDATE_VERSION' , 1195); define('UPDATE_VERSION' , 1196);
/** /**
* *