It's well-documented how to retrieve one record quickly or how to retrieve multiple records inefficiently (by plucking all IDs). I'm wondering what is the fastest way to retrieve N records from a table of millions of records.
I've found with a 3M row MariaDB table, plucking all IDs takes 10+ seconds and ordering by rand() takes over a minute. This makes me think N separate random offset calls (after finding the total table count) could be quicker, assuming N is relatively low. I'm still wondering if there's a faster way or if not, some trick to make the random offset calls in a single query.