Mailing List Archive

Watchlist query needs optimizing
The watchlist is just damn slow. Would anyone care to take a look at it
and find a way to make it more efficient?

Currently:

SELECT DISTINCT
cur_id,cur_namespace,cur_title,cur_comment,
cur_user,cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new
FROM cur,watchlist
WHERE wl_user={$uid} AND wl_title=cur_title
AND (cur_namespace=wl_namespace OR cur_namespace=wl_namespace+1)
ORDER BY inverse_timestamp {$dolimit}

This ends up EXPLAINED as:

+-----------+------+----------------------------------------------+-----------+---------+--------------------+------+----------------------------------------------------------+
| table | type | possible_keys | key | key_len | ref | rows | Extra |
+-----------+------+----------------------------------------------+-----------+---------+--------------------+------+----------------------------------------------------------+
| watchlist | ref | wl_user | wl_user | 4 | const | 1 | where used; Using index; Using temporary; Using filesort |
| cur | ref | cur_namespace,cur_title,name_title_timestamp | cur_title | 255 | watchlist.wl_title | 1 | where used |
+-----------+------+----------------------------------------------+-----------+---------+--------------------+------+----------------------------------------------------------+

Temporary table and filesort are not friendly.

-- brion vibber (brion @ pobox.com)