I noticed that you are also doing a RIGHT join and then excluding anything that is blank in your where clause. A right join is typically more expensive than an inner join, so I would rewrite it to be:
INNER JOIN user ON ur.userid = user.referrerid
And remove the:
WHERE user.referrerid != ''
as the INNER JOIN will implicitly eliminate blanks in the join.