From 454fbc8ad7c2f849d0540a2ab2fbab2af2270bd4 Mon Sep 17 00:00:00 2001 From: Michael Date: Sun, 21 Feb 2021 10:37:15 +0000 Subject: [PATCH] Queries without indexes --- src/Protocol/Diaspora.php | 5 +++-- src/Worker/CleanItemUri.php | 2 +- static/dbstructure.config.php | 10 ++++++++-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/Protocol/Diaspora.php b/src/Protocol/Diaspora.php index 14c8df1a7..79151c140 100644 --- a/src/Protocol/Diaspora.php +++ b/src/Protocol/Diaspora.php @@ -3103,8 +3103,9 @@ class Diaspora // In fact it doesn't matter which user sends this - but it is needed by the protocol. // If the item belongs to a user, we take this user id. if ($item['uid'] == 0) { - $condition = ['verified' => true, 'blocked' => false, 'account_removed' => false, 'account_expired' => false]; - $first_user = DBA::selectFirst('user', ['uid'], $condition); + $condition = ['verified' => true, 'blocked' => false, + 'account_removed' => false, 'account_expired' => false, 'account-type' => User::ACCOUNT_TYPE_PERSON]; + $first_user = DBA::selectFirst('user', ['uid'], $condition, ['order' => ['uid']]); $owner = User::getOwnerDataById($first_user['uid']); } else { $owner = User::getOwnerDataById($item['uid']); diff --git a/src/Worker/CleanItemUri.php b/src/Worker/CleanItemUri.php index c883083b5..84ef537c4 100644 --- a/src/Worker/CleanItemUri.php +++ b/src/Worker/CleanItemUri.php @@ -52,7 +52,7 @@ class CleanItemUri $ids = array_column($rows, 'id'); DBA::delete('item-uri', ['id' => $ids]); $affected_count += DBA::affectedRows(); - Logger::info('Updated', ['rows' => $affected_count]); + Logger::info('Deleted', ['rows' => $affected_count]); } DBA::close($uris); Logger::notice('Orphaned URI-ID entries removed', ['rows' => $affected_count]); diff --git a/static/dbstructure.config.php b/static/dbstructure.config.php index 380e24699..d04683103 100644 --- a/static/dbstructure.config.php +++ b/static/dbstructure.config.php @@ -147,6 +147,7 @@ return [ "PRIMARY" => ["uid"], "nickname" => ["nickname(32)"], "parent-uid" => ["parent-uid"], + "guid" => ["guid"], ] ], "contact" => [ @@ -317,7 +318,8 @@ return [ "name" => ["type" => "varchar(100)", "not null" => "1", "default" => "", "comment" => ""] ], "indexes" => [ - "PRIMARY" => ["id"] + "PRIMARY" => ["id"], + "name" => ["name"] ] ], // Main tables @@ -375,6 +377,7 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], + "installed_name" => ["installed", "name"], "name" => ["UNIQUE", "name"], ] ], @@ -480,6 +483,7 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], + "expire" => ["expire"], ] ], "config" => [ @@ -693,6 +697,7 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], + "priority" => ["priority"], "hook_file_function" => ["UNIQUE", "hook", "file", "function"], ] ], @@ -1382,7 +1387,8 @@ return [ ], "indexes" => [ "PRIMARY" => ["id"], - "uid" => ["uid"], + "uid_term" => ["uid", "term(64)"], + "term" => ["term(64)"] ] ], "session" => [