Separate from T187579, we want to be able to query logging where the target is an IP range (individual IPs are stored as the log_title, with a log_namespace of 2).
One idea is to use log_search (T187579#3979710). Let's use blocks of IPs as an example. So every time a block is made on an IP, we'd call ManualLogEntry::setRelations() to store information on it. We'd use a new type of ls_field, perhaps called ip_log_title, that indicates the ls_value is a hexadecimal representation of the IP address (which is the log_title for the corresponding row in logging). That way we can use BETWEEN on log_search to get log entries of IPs within a range. We'd need to also filter by log_type, in our example block in order to get the block log of all IPs within a given range.
On enwiki there are some 3.5 million blocks of IPs in logging -- a rough guess judging by SELECT COUNT(*) FROM logging WHERE log_type = 'block' AND log_title rlike '^[1-9]' AND log_page = 0, and again without log_page = 0 (includes IPs that have a userpage and accounts that start with a number).
Do we think log_search could work?
Soliciting feedback from DBAs and other smart people... thank you!