mysql 随机查询,,效率优化

select * from bl_keylist where Title like '%bags%' or Title like '%handbags%' order by rand() limit 0,12
 效率太低了点。。


换成这样

SELECT * FROM bl_keylist AS r1 JOIN (SELECT ROUND(RAND() * (SELECT MAX(id) FROM bl_keylist)) AS id) AS r2 WHERE r1.id >= r2.id and (Title like '%bags%' or Title like '%handbags%') ORDER BY r1.id ASC LIMIT 12;

 宇宙的速度


mysql 随机查询,,效率优化

你可能感兴趣的:(mysql)