Optimizing query for large table with `rand()` ordering
There is no good way to do ORDER BY RAND() LIMIT 1, but this has several suggestions.  Some depend on AUTO_INCREMENT, some based on an extra column.