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

@ -1,6 +1,6 @@
-- ------------------------------------------
-- Friendica 2025.02-dev (Interrupted Fern)
-- DB_UPDATE_VERSION 1576
-- DB_UPDATE_VERSION 1577
-- ------------------------------------------
@ -1609,7 +1609,7 @@ CREATE TABLE IF NOT EXISTS `post-user` (
`psid` int unsigned COMMENT 'ID of the permission set of this post',
PRIMARY KEY(`id`),
UNIQUE INDEX `uid_uri-id` (`uid`,`uri-id`),
INDEX `uri-id` (`uri-id`),
INDEX `uri-id_origin_deleted` (`uri-id`,`origin`,`deleted`),
INDEX `parent-uri-id` (`parent-uri-id`),
INDEX `thr-parent-id` (`thr-parent-id`),
INDEX `external-id` (`external-id`),