MySQL select 10 random rows from 600K rows fast

后端 未结 26 3010
粉色の甜心
粉色の甜心 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:49

    I Use this query:

    select floor(RAND() * (SELECT MAX(key) FROM table)) from table limit 10
    

    query time:0.016s

提交回复
热议问题