Created
July 7, 2022 17:10
-
-
Save agarman/d7952471d885681fbc5aa854f47f954d to your computer and use it in GitHub Desktop.
MySQL SELECT RAND() rows FAST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
* | |
FROM {{db}}.{{nm}} | |
WHERE | |
rand() < 0.1 | |
AND UPDATED_TIMESTAMP BETWEEN CURRENT_DATE() - 7 AND DATE_SUB(CURRENT_TIME(), INTERVAL 2 HOUR) | |
LIMIT 10; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment