The reason why I cannot rely on self generated random numbers between 1 and max(file_id) is:
* The file_ids may not be continuous.
* Some rows will be filtered in WHERE condition; like: allow_play='Y', and if its (row whose allow_play is 'N') file_id was generated, there will be no data.
What about generating a pool of valid file_ids in a different table.
And then again randomly selecting file_ids still by ORDER BY RAND() LIMIT 30.
Building a comma separated list of those file_ids, and querying with the WHERE part:
I think it's ORDER BY RAND() will run much faster than on the table physical_files.
WHERE file_id IN(r,a,n,d,o,m,l,y,...,f,i,l,e,_,i,d,s)
This pool has only one column in the table: file_id, and can be indexed.
Or, even made the primary key, as like in physical_files.