Wikia/app — pull request #1277 by macbre (2013-08-07 13:00:20+00:00)
Title: BAC-589: improve images popularity in ImageServing

Add a query that gets all images being redirect to an image we're getting popularity for

```mysql
mysql> explain (select /* ImageServingDriverMainNS::getImagesPopularity::redirects Macbre */ page_title, rd_title from `redirect` left join page on page_id = rd_from where rd_namespace = 6 AND rd_title = 'Jenson_Button_bahrain_2012.jpg' limit 5) UNION ALL (select page_title, rd_title from `redirect` left join page on page_id = rd_from where rd_namespace = 6 AND rd_title = 'Flag_of_the_United_Kingdom.svg' limit 5);
+----+--------------+------------+--------+---------------+-------------+---------+---------------------+------+--------------------------+
| id | select_type | table | type | possible_keys | key | key_len | ref | rows | Extra |
+----+--------------+------------+--------+---------------+-------------+---------+---------------------+------+--------------------------+
| 1 | PRIMARY | redirect | ref | rd_ns_title | rd_ns_title | 261 | const,const | 1 | Using where; Using index |
| 1 | PRIMARY | page | eq_ref | PRIMARY | PRIMARY | 4 | f1.redirect.rd_from | 1 | |
| 2 | UNION | redirect | ref | rd_ns_title | rd_ns_title | 261 | const,const | 1 | Using where; Using index |
| 2 | UNION | page | eq_ref | PRIMARY | PRIMARY | 4 | f1.redirect.rd_from | 1 | |
| NULL | UNION RESULT | | ALL | NULL | NULL | NULL | NULL | NULL | |
+----+--------------+------------+--------+---------------+-------------+---------+---------------------+------+--------------------------+
5 rows in set (0.00 sec)
```

@moli - please review the SQL

Don't merge it - waiting for QA