Page MenuHomePhabricator

Replication of dewiki_p table 'recentchanges' doesn't seem to have indices
Closed, InvalidPublicBUG REPORT

Description

Due to this script and many other documentation 'recentchanges' should have indices for columns like (rc_actor, rc_timestamp) or (rc_timestamp).

But, when I execute:

MariaDB [dewiki_p]> SELECT rc_id, rc_timestamp, rc_actor, rc_title FROM recentchanges WHERE rc_actor=16393 AND rc_timestamp=20200325211738;
+-----------+----------------+----------+----------+
| rc_id     | rc_timestamp   | rc_actor | rc_title |
+-----------+----------------+----------+----------+
| 287549619 | 20200325211738 |    16393 | Euku     |
+-----------+----------------+----------+----------+
1 row in set (1.73 sec)

It takes about 1.5 seconds in average! It seems to me the index is not used.

SHOW EXPLAIN FOR 298722742;
...
+------+-------------+---------------+------+---------------+------+---------+------+---------+-------------+
| id   | select_type | table         | type | possible_keys | key  | key_len | ref  | rows    | Extra       |
+------+-------------+---------------+------+---------------+------+---------+------+---------+-------------+
|    1 | SIMPLE      | recentchanges | ALL  | rc_timestamp  | NULL | NULL    | NULL | 1186155 | Using where |
+------+-------------+---------------+------+---------------+------+---------+------+---------+-------------+

When I use the key, it's fast:

MariaDB [dewiki_p]> SELECT rc_id, rc_timestamp, rc_actor, rc_title FROM recentchanges WHERE rc_id=287549619;
+-----------+----------------+----------+----------+
| rc_id     | rc_timestamp   | rc_actor | rc_title |
+-----------+----------------+----------+----------+
| 287549619 | 20200325211738 |    16393 | Euku     |
+-----------+----------------+----------+----------+
1 row in set (0.00 sec)

Event Timeline

sorry, didn't saw 'recentchanges_userindex'.