This kind of query might need tunning:
SELECT /* BatchRowIterator::next */ cl_from,cl_to FROM `categorylinks` WHERE cl_type = 'subcat' AND cl_from IN (92967652,234494,24559020,960551,3007520,76398273,6972234,363488,2257260,4157420,89319925,84920900,41797907,61421859,92055128,9221880,14562,26762776,33298380,65449552,3795363,66235719,42442426,89319828,27708617,2563533,66701920,22548996,108484,25232065,6846286,43665564,2257433,8811984,84203487,3837544,5324927,8645978,'',805218,1078394,81978764,391851) ORDER BY cl_from ASC,cl_to ASC LIMIT 200 root@db1121.eqiad.wmnet[commonswiki]> show explain for 751641971; +------+-------------+---------------+-------+---------------+---------+---------+------+-----------+-----------------------------+ | id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra | +------+-------------+---------------+-------+---------------+---------+---------+------+-----------+-----------------------------+ | 1 | SIMPLE | categorylinks | index | PRIMARY | PRIMARY | 261 | NULL | 396988884 | Using where; Using filesort | +------+-------------+---------------+-------+---------------+---------+---------+------+-----------+-----------------------------+ 1 row in set, 1 warning (0.348 sec)
I am not sure who owns this piece of code, the only thing I have been able to find at gerrit is: https://gerrit.wikimedia.org/r/c/mediawiki/core/+/299578
If anyone knows better tags for this, please feel free to change/add them!