Zamówienie mysql według rand limit 1 naprawdę powolny

function get_random_row($mytable,$conn){
	$table_max_id = $conn->query("SELECT id FROM $mytable ORDER BY id DESC LIMIT 0, 1")[0]["id"];
	$rand_id=rand(1,$table_max_id);
	$random_result = $conn->query("select * from $mytable where id = $rand_id");
  	
	#note: if you are missing some id's, we can call again until we get hit
  	if(!$random_result){
    	return get_random_row($mytable,$conn);
    }
  
  	return $random_result;
}
Friendly Hawk