More indexes / performance for "pinned" improved

This commit is contained in:
Michael 2021-03-10 13:25:37 +00:00
parent df547ba73f
commit d30ec1eb58
4 changed files with 13 additions and 13 deletions

View File

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2021.03-rc (Red Hot Poker)
-- DB_UPDATE_VERSION 1410
-- DB_UPDATE_VERSION 1411
-- ------------------------------------------
@ -197,6 +197,9 @@ CREATE TABLE IF NOT EXISTS `contact` (
INDEX `uid_network_self_lastupdate` (`uid`,`network`,`self`,`last-update`),
INDEX `uid_lastitem` (`uid`,`last-item`),
INDEX `baseurl` (`baseurl`(64)),
INDEX `uid_contact-type` (`uid`,`contact-type`),
INDEX `uid_self_contact-type` (`uid`,`self`,`contact-type`),
INDEX `self_network_uid` (`self`,`network`,`uid`),
INDEX `gsid` (`gsid`),
FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON UPDATE RESTRICT ON DELETE CASCADE,
FOREIGN KEY (`gsid`) REFERENCES `gserver` (`id`) ON UPDATE RESTRICT ON DELETE RESTRICT
@ -1489,6 +1492,7 @@ CREATE VIEW `post-user-view` AS SELECT
`post-thread-user`.`pubmail` AS `pubmail`,
`post-user`.`visible` AS `visible`,
`post-thread-user`.`starred` AS `starred`,
`post-thread-user`.`pinned` AS `pinned`,
`post-user`.`unseen` AS `unseen`,
`post-user`.`deleted` AS `deleted`,
`post-user`.`origin` AS `origin`,
@ -1648,6 +1652,7 @@ CREATE VIEW `post-thread-user-view` AS SELECT
`post-thread-user`.`ignored` AS `ignored`,
`post-user`.`visible` AS `visible`,
`post-thread-user`.`starred` AS `starred`,
`post-thread-user`.`pinned` AS `pinned`,
`post-thread-user`.`unseen` AS `unseen`,
`post-user`.`deleted` AS `deleted`,
`post-thread-user`.`origin` AS `origin`,

View File

@ -320,17 +320,7 @@ class Post
AND NOT EXISTS (SELECT `cid` FROM `user-contact` WHERE `uid` = ? AND `cid` = `owner-id` AND `ignored` AND `gravity` = ?)",
0, Contact::SHARING, Contact::FRIEND, GRAVITY_PARENT, 0, $uid, $uid, $uid, $uid, GRAVITY_PARENT, $uid, GRAVITY_PARENT]);
$select_string = '';
if (in_array('pinned', $selected)) {
$selected = array_flip($selected);
unset($selected['pinned']);
$selected = array_flip($selected);
$select_string = "(SELECT `pinned` FROM `post-thread-user` WHERE `uri-id` = `" . $view . "`.`uri-id` AND uid=`" . $view . "`.`uid`) AS `pinned`, ";
}
$select_string .= implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
$select_string = implode(', ', array_map([DBA::class, 'quoteIdentifier'], $selected));
$condition_string = DBA::buildCondition($condition);
$param_string = DBA::buildParameter($params);

View File

@ -55,7 +55,7 @@
use Friendica\Database\DBA;
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1410);
define('DB_UPDATE_VERSION', 1411);
}
return [
@ -256,6 +256,9 @@ return [
"uid_network_self_lastupdate" => ["uid", "network", "self", "last-update"],
"uid_lastitem" => ["uid", "last-item"],
"baseurl" => ["baseurl(64)"],
"uid_contact-type" => ["uid", "contact-type"],
"uid_self_contact-type" => ["uid", "self", "contact-type"],
"self_network_uid" => ["self", "network", "uid"],
"gsid" => ["gsid"]
]
],

View File

@ -64,6 +64,7 @@
"pubmail" => ["post-thread-user", "pubmail"],
"visible" => ["post-user", "visible"],
"starred" => ["post-thread-user", "starred"],
"pinned" => ["post-thread-user", "pinned"],
"unseen" => ["post-user", "unseen"],
"deleted" => ["post-user", "deleted"],
"origin" => ["post-user", "origin"],
@ -221,6 +222,7 @@
"ignored" => ["post-thread-user", "ignored"],
"visible" => ["post-user", "visible"],
"starred" => ["post-thread-user", "starred"],
"pinned" => ["post-thread-user", "pinned"],
"unseen" => ["post-thread-user", "unseen"],
"deleted" => ["post-user", "deleted"],
"origin" => ["post-thread-user", "origin"],