https://bugzilla.wikimedia.org/show_bug.cgi?id=65332

            Bug ID: 65332
           Summary: infoAction::pageCounts use rev_user instead of
                    rev_user_text
           Product: MediaWiki
           Version: 1.23-git
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: Database
          Assignee: [email protected]
          Reporter: [email protected]
       Web browser: ---
   Mobile Platform: ---

InfoAction::pageCounts() does these two queries:

// Total number of distinct authors
$authors = (int)$dbr->selectField(
    'revision',
    'COUNT(DISTINCT rev_user_text)',
    array( 'rev_page' => $id ),
    __METHOD__
);

SELECT COUNT(DISTINCT rev_user_text) FROM `revision` WHERE rev_page = '453'
LIMIT 1;

// Recent number of distinct authors
$authors = (int)$dbr->selectField(
    'revision',
    'COUNT(DISTINCT rev_user_text)',
    array(
        'rev_page' => $id,
        "rev_timestamp >= " . $dbr->addQuotes( $threshold )
    ),
    __METHOD__
);

SELECT COUNT(DISTINCT rev_user_text) FROM `revision` WHERE rev_page = '453' AND
rev_timestamp >= '20140415000000' LIMIT 1;

Generally OK except for certain pages which have quite a lot of hits, such as
the wikidata example id 443 above. Sometimes examples run for up to 300s if
data is cold. Obviously these results are for caching, but they correspond to
disk io spikes which would be nice to avoid.

These versions using rev_user are faster:

SELECT COUNT(DISTINCT rev_user) FROM `revision` WHERE rev_page = '453' LIMIT 1;

SELECT COUNT(DISTINCT rev_user) FROM `revision` WHERE rev_page = '453' AND
rev_timestamp >= '20140415000000' LIMIT 1;

Two reasons:

1. Counting integers is marginally faster than strings. Small deal.

2. Optimizer choose to retrieve the results entirely from existing indexes
without touching rows at all. Big deal!

-- 
You are receiving this mail because:
You are the assignee for the bug.
You are on the CC list for the bug.
_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to