<div dir="ltr">On Wed, Nov 12, 2014 at 11:06 AM, Maximilian Doerr <span dir="ltr"><<a href="mailto:maximilian.doerr@gmail.com" target="_blank">maximilian.doerr@gmail.com</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word">My knowledge of MySQL is pathetic to be honest.  It’s definitely something I should familiarize myself with.  Could you explain that to me so a pickle could understand it? :/</div></blockquote><div><br></div><div>Unfortunately, I don't speak pickle. But I'll try to clarify.<span class=""><br><br></span><br>"enwiki_p.revision_userindex" is a view (along with everything else in enwiki_p, I believe), which is basically a pretend 
table that's really populated by a SELECT query (in this case, from 
"enwiki.revision"). You can use "SHOW CREATE TABLE 
enwiki_p.revision_userindex;" to see that query if you want. So when you 
select from the view, it basically rewrites your query to incorporate 
that other select.<br><div><blockquote class="gmail_quote" type="cite"><div><div><div class="h5"><div dir="ltr"><div><span style="font-family:courier new,monospace">+------+-------------+----------+--------+---------------------------------------+----------------+---------+--------------------------+-------+-----------------------------+<br>| id   | select_type | table    | type   | possible_keys                         | key            | key_len | ref                      | rows  | Extra                       |<br>+------+-------------+----------+--------+---------------------------------------+----------------+---------+--------------------------+-------+-----------------------------+<br>|    1 | SIMPLE      | revision | ref    | PRIMARY,page_timestamp,user_timestamp | user_timestamp | 4       | const                    | 29186 | Using where; Using filesort |<br>|    1 | SIMPLE      | page     | eq_ref | PRIMARY                               | PRIMARY        | 4       | enwiki.revision.rev_page |     1 |                             |<br></span></div></div></div></div></div></blockquote><div>The "key" column here tells us that it is in fact using the user_timestamp index to find the rows in the revision table. Which is good, indexing isn't broken.<br><br></div><div>The "Extra" column tells us a few things.<br><ul><li>It doesn't have "Using index", so it's having to actually fetch the row from the table instead of just getting what it needs from the index (in this case, that's because the view filters based on rev_deleted). That makes things slightly slower, especially if you're having to hit cold pages (i.e. blocks from the disk that aren't already cached in memory).<br></li><li>"Using where" tells us that it might to throw away some of the rows that it fetched, thanks to a WHERE clause (again, the rev_deleted check).</li><li>"Using filesort" means that it's going to load all the rows into memory (or worse, write them to a temp file) and then sort them to put them in ORDER BY order. This can get really slow if there are a lot of them. I don't know why it's deciding it needs to do this here, since the user_timestamp index should already be giving the rows in the asked-for order.<br></li></ul></div></div></div></div>And then, of course, it's having to fetch rows from the page table as well, which could again be hitting cold pages.<br></div><div class="gmail_extra"><br clear="all"><br>-- <br><div class="gmail_signature">Brad Jorsch (Anomie)<br>Software Engineer<br>Wikimedia Foundation</div>
</div></div>