Skip to content

Instantly share code, notes, and snippets.

@sprite2005
Created October 26, 2010 14:58
Show Gist options
  • Save sprite2005/647047 to your computer and use it in GitHub Desktop.
Save sprite2005/647047 to your computer and use it in GitHub Desktop.
# Time: 101026 9:56:40
# User@Host: jizztag[jizztag] @ theplanet.com [216.40.221.50]
# Query_time: 12.310083 Lock_time: 0.000210 Rows_sent: 528 Rows_examined: 1044443
SET timestamp=1288105000;
SELECT tags.*, COUNT(*) AS count FROM `tags` LEFT OUTER JOIN taggings ON tags.id = taggings.tag_id AND taggings.context = 'tags' INNER JOIN videos ON videos.id = taggings.taggable_id WHERE (taggings.taggable_type = 'Video') AND (taggings.taggable_id IN(SELECT videos.id FROM `videos` JOIN taggings videos_taggings_hardcore_365 ON videos_taggings_hardcore_365.taggable_id = videos.id AND videos_taggings_hardcore_365.taggable_type = 'Video' AND videos_taggings_hardcore_365.tag_id = 32 JOIN taggings videos_taggings_fucking_904 ON videos_taggings_fucking_904.taggable_id = videos.id AND videos_taggings_fucking_904.taggable_type = 'Video' AND videos_taggings_fucking_904.tag_id = 158)) GROUP BY tags.id, tags.name HAVING COUNT(*) > 0 ORDER BY count desc LIMIT 600;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment