Created
May 13, 2013 14:09
-
-
Save bbn/5568561 to your computer and use it in GitHub Desktop.
slow queries coming from related posts plugin
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 | |
target.post_id, sum(target.weight * log(34759 / least(34759, freqs.freq))) as score | |
FROM | |
wp_1_wp_rp_tags as target, | |
(SELECT label, count(1) as freq FROM wp_1_wp_rp_tags | |
WHERE label IN ('P_audacity', 'P_runtime', 'P_soundflower', 'C_articles', 'C_tutorials', 'A_max', 'A_mac', 'A_softwar', 'A_audio', 'A_sketch', 'A_os', 'A_free', 'A_download', 'A_aa', 'A_patch', 'A_project', 'A_instal', 'A_machin', 'A_product', 'A_sound') | |
GROUP BY label | |
) as freqs | |
WHERE | |
target.post_id NOT IN ('17274') AND | |
target.label=freqs.label AND | |
target.label IN ('P_audacity', 'P_runtime', 'P_soundflower', 'C_articles', 'C_tutorials', 'A_max', 'A_mac', 'A_softwar', 'A_audio', 'A_sketch', 'A_os', 'A_free', 'A_download', 'A_aa', 'A_patch', 'A_project', 'A_instal', 'A_machin', 'A_product', 'A_sound') AND | |
target.post_id NOT IN ( | |
SELECT post_id FROM wp_1_wp_rp_tags | |
WHERE label IN ('C_blog', 'C_company', 'C_newsletter', 'C_press releases', 'C_review', 'C_Uncategorized') | |
) | |
GROUP BY target.post_id | |
ORDER BY score desc | |
LIMIT 6; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment