lundi 23 mars 2015

Flag large number random records in a MySQL database - one time only

In my database table I've got 5 columns, id, l_num, s_num, win, claimed. There are 415,000 records. How would I randomly select 20,000 of those records and update the record with a 1 in the win field?


I understand that I could use SELECT * FROM tableName ORDER BY RAND() LIMIT 20000 to select those random records, but I've also read that this type of select would be inefficient for a large number.


I only need to perform this once on the database. Once all the records are flagged, we're simply checking against that flag one at a time.


Aucun commentaire:

Enregistrer un commentaire