DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

Richard has posted 22 posts at DZone. View Full User Profile

Analyse A MySQL Query For Inefficiencies

  • submit to reddit
        // description of your code here

EXPLAIN SELECT t2.dbid, t2.tag, COUNT(t2.dbid) * 20 AS match_count
FROM tags AS t1, tags AS t2
WHERE t1.dbid = '105318'
AND t2.tag = t1.tag
AND t1.dbid != t2.dbid
GROUP BY t2.dbid
ORDER BY match_count;