Author: afeldman
Description:
This query is regularly taking up to 8 seconds on enwiki and will worsen over time in current form. The ORDER BY is satisfied by the af_relevance_sort_af_id index on aft_article_feedback, but that does nothing for any of the WHERE constraints on that table. af_page_id would be the most reasonable to include in an index that can satisfy the ORDER BY. That should help today but over time, a large number of rows will still have to be scanned for popular articles, so this needs a better long term solution. A search engine would handle this much better.
SELECT /* ArticleFeedbackv5Fetch::run */ af_id, af_net_helpfulness, af_relevance_sort, rating.aa_response_boolean AS yes_no FROM aft_article_feedback LEFT JOIN aft_article_answer rating ON ((rating.aa_feedback_id = af_id) AND rating.aa_field_id IN ('-1', '1', '16') ) LEFT JOIN aft_article_answer comment ON ((comment.aa_feedback_id = af_id) AND comment.aa_field_id IN ('-1', '2', '17') ) WHERE (af_is_deleted IS FALSE) AND (af_is_hidden IS FALSE) AND ((af_is_featured IS TRUE OR af_has_comment is true OR af_net_helpfulness > 0) AND af_relevance_score > -5) AND af_page_id = '5043734' AND (( af_form_id = 1 OR af_form_id = 6 )) ORDER BY af_relevance_sort ASC, af_id ASC LIMIT 51
Version: unspecified
Severity: normal