Faster count queries when updating the info about current node

MySQL optimiser seems to prefer a full table scan of `post-user`
table in the count query mentioned in issue #14763. When the origin
and deleted columns are added to the index, the IN-query part of
the query can be done with index-only scan, which is much faster.

Adding the columns in the order

    uri-id, origin, deleted

allows some other queries to also use it when checking
for uri-id and origin.

Fixes #14763
This commit is contained in:
Esko Arajärvi 2025-02-04 18:46:06 +02:00
parent edbf86449d
commit 25bb9b12c1
3 changed files with 29 additions and 29 deletions

View file

@ -44,7 +44,7 @@ use Friendica\Database\DBA;
// This file is required several times during the test in DbaDefinition which justifies this condition
if (!defined('DB_UPDATE_VERSION')) {
define('DB_UPDATE_VERSION', 1576);
define('DB_UPDATE_VERSION', 1577);
}
return [
@ -1604,7 +1604,7 @@ return [
"indexes" => [
"PRIMARY" => ["id"],
"uid_uri-id" => ["UNIQUE", "uid", "uri-id"],
"uri-id" => ["uri-id"],
"uri-id_origin_deleted" => ["uri-id", "origin", "deleted"],
"parent-uri-id" => ["parent-uri-id"],
"thr-parent-id" => ["thr-parent-id"],
"external-id" => ["external-id"],