Could not successfully run query (SELECT u.*, p.filename photo_filename FROM users u, user_photos p WHERE p.user_id=u.id AND p.is_main=1 AND u.active=1 AND u.sex='male' GROUP BY u.id ORDER BY RAND() LIMIT 1) from DB: Incorrect key file for table '/var/tmp/#sql2b87_33183a_1.MYI'; try to repair it