4m Rows in MySQL, ~5 Minutes to Run Query
SELECT  u.usrid, u.username, u.rank, u.extras, x.dtime
    FROM  
      ( SELECT  userid, MAX(datetime) dtime
            FROM  log
            GROUP BY  userid
            HAVING  dtime &lt; NOW() - INTERVAL 1 YEAR 
      ) AS x
    JOIN  users u ON u.usrid = x.userid
    WHERE  ( u.rank = 'P'
              OR  u.extras LIKE '%W%' 
           )
    ORDER BY  x.dtime DESC 


Plus

 INDEX(usrid, datetime) -- in `log`


(I assume usrid is the PRIMARY KEY in users.)

Is size an issue?  Yes and no.  With the right indexes and queries, etc, billion-row tables can work fine.  In your case, it is dubious...  The subquery will probably produce 500K distinct users from its GROUP BY.  Then the HAVING will shrink the number.  What's left needs to be looked up in users and further filtered.  Finally another sort (ORDER BY) before delivering the results.

I think that newer versions of MySQL will leapfrog through the INDEX I suggested, landing on only 500K index rows, not all 4M.

If you think the rank and extras do a better filtering than MAX(datetime), then a different approach might be faster.