Page MenuHomePhabricator

Toolforge view for blocks is very slow
Closed, ResolvedPublic

Description

This query used to take under a second to run:

SET STATEMENT max_statement_time = 300 FOR
SELECT * FROM (
    SELECT
        revs.rev_id AS `id`,
        revs.rev_timestamp AS `timestamp`,
        revs.rev_minor_edit AS `minor`,
        revs.rev_len AS `length`,
        (CAST(revs.rev_len AS SIGNED) - IFNULL(parentrevs.rev_len, 0)) AS `length_change`,
        actor_user AS user_id,
        actor_name AS username,
        comment_text AS `comment`,
        revs.rev_sha1 AS `sha`,
        revs.rev_deleted AS `deleted`
    FROM `enwiki_p`.`revision` AS revs
    LEFT JOIN `enwiki_p`.`actor` ON revs.rev_actor = actor_id
    LEFT JOIN `enwiki_p`.`revision` AS parentrevs ON (revs.rev_parent_id = parentrevs.rev_id)
    LEFT OUTER JOIN `enwiki_p`.`comment` ON comment_id = revs.rev_comment_id
    WHERE  revs.rev_page = 22929254
    ORDER BY revs.rev_timestamp DESC
) a
ORDER BY `timestamp` ASC

Running EXPLAIN on this query shows two dependent and unindexed subqueries on the entire block table, slowing the query down to 1 minute or longer.

Event Timeline

@taavi reports that "looks like the index maintenance script for the index in https://gerrit.wikimedia.org/r/c/operations/puppet/+/1016066 was never ran"

Mentioned in SAL (#wikimedia-cloud) [2024-04-05T14:17:37Z] <taavi> run maintain-replica-indexes on clouddb1017 T361945

Mentioned in SAL (#wikimedia-cloud) [2024-04-05T14:27:01Z] <taavi> run maintain-replica-indexes on remaining analytics replicas T361945

Mentioned in SAL (#wikimedia-cloud) [2024-04-05T14:37:01Z] <taavi> run maintain-replica-indexes on all web replicas T361945

@taavi, do you have any theory about how/why @tstarling's actions in T355034: Deploy new block_target schema weren't sufficient?

Mentioned in SAL (#wikimedia-operations) [2024-04-04T02:48:57Z] <TimStarling> ran maintain-views on clouddb1013-1019 (T355034)

maintain-views and maintain-replica-indexes are two separate script. https://gerrit.wikimedia.org/r/1016066 changed the configuration for both scripts, but apparently only maintain-views was ran.