Custom taxonomies making WP very slow – Way to fix?

This has nothing to do with custom taxonomies. I was using a snippet of code from the default ‘twentytwelve’ theme for image.php that was looping through every single post in the blog to get child attachments, and thus the taxonomy associations for each of those posts. Amending my image.php by removing this foreach() loop fixed the issue.