Browse Source

Some optimized sql queries

pull/2570/head
Michael Vogel 6 years ago
parent
commit
fc66a86dc5
  1. 2
      boot.php
  2. 4
      database.sql
  3. 2
      include/dbstructure.php
  4. 2
      include/group.php
  5. 2
      mod/profile.php
  6. 2
      update.php

2
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.

4
database.sql

@ -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`),

2
include/dbstructure.php

@ -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"),

2
include/group.php

@ -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`

2
mod/profile.php

@ -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

2
update.php

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

Loading…
Cancel
Save