I optimised our news feed stored procedure to be 10x faster (with 10x less code)
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 id, url, json, | |
TIMESTAMPDIFF(HOUR, create_date, now()) AS hours_old, | |
( ( views + (shares * 25) | |
+ IF(FIND_IN_SET('arsenal-fc,liverpool-fc', post_tags), 10000, 0) ) | |
/ 1 | |
) total | |
FROM articles WHERE | |
category = 'sport' AND | |
FIND_IN_SET(id, '4964027,4963575') = false | |
HAVING | |
hours_old < 72 | |
ORDER BY total DESC LIMIT 50; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment