Author: bugzilla_wikipedia_org.to.jamesd
Description:
The current block query from Block::load is:
mysql> explain select * from ipblocks where
(ipb_address='83.24.12.97' or ipb_user=73855);
+----------+------+----------------------+------+---------+--
----+------+-------------+
table | type | possible_keys | key | key_len | |
ref | rows | Extra |
+----------+------+----------------------+------+---------+--
----+------+-------------+
ipblocks | ALL | ipb_address,ipb_user | NULL | NULL | |
NULL | 731 | Using where |
+----------+------+----------------------+------+---------+--
----+------+-------------+
Note that it's doing a full table scan - no index use.
Change to this:
explain select * from ipblocks where
ipb_address='83.24.12.97' union select * from ipblocks where
ipb_user=73855;
+----------+------+---------------+-------------+---------+--
-----+------+-------------+
table | type | possible_keys | key | key_len | |
ref | rows | Extra |
+----------+------+---------------+-------------+---------+--
-----+------+-------------+
ipblocks | ref | ipb_address | ipb_address | 40 | |
const | 1 | Using where |
ipblocks | ref | ipb_user | ipb_user | 4 | |
const | 1 | Using where |
+----------+------+---------------+-------------+---------+--
-----+------+-------------+
Two parts with a union, so each part can use an index.
Version: 1.4.x
Severity: normal