MySQL select 10 random rows from 600K rows fast

后端 未结 26 3001
粉色の甜心
粉色の甜心 2020-11-21 05:06

How can I best write a query that selects 10 rows randomly from a total of 600k?

26条回答
  •  伪装坚强ぢ
    2020-11-21 05:27

    I guess this is the best possible way..

    SELECT id, id * RAND( ) AS random_no, first_name, last_name
    FROM user
    ORDER BY random_no
    

提交回复
热议问题