title: Optimize SQL inner join on a 36 million row table with 3 columns
body: <p>We have a few of these types of tables with roughly 30 million ~ 80 million rows per table.
  We are interested in running analysis on the table, but the queries take long time (queries takes over 10 minute) to execute. Can SQL guru spot any obvious optimization we could apply to fasten the query execution ? </p>
  
  <p>URL contains information about sql schema, 
  sample rows 
  and the query we wanted to execute at the very bottom.
  We've also added an index on <code>userid</code> but the query still takes a long time.
  <a href="http://pastebin.com/raw.php?i=pn9Kyg2z" rel="nofollow">http://pastebin.com/raw.php?i=pn9Kyg2z</a>
  table created with innodb on mariadb. Server has 12G allocated to buffer pool</p>