The site I help run has a few pages which we update with new images from time to time, and so the number of attachments to these pages has built up quite a lot over time. The result is a LARGE number of rewrite rules for each attachment which was slowing down the site.
Now like a lot of sites, we have no interest in the raw attachment pages anyway, so I took the unusual measure of removing all those rewrite rules -- by hacking page_uri_index function in wp-includes/rewrite.php. I could see no way of getting the same results using hooks/filters (though, eg a filter on $attachments in that function would do the trick and I might turn my hack into that as it would make the core hack a single line.)
I have seen people suggest detaching attachments by resorting to raw if simple SQL changes.
My question is has anyone got better, cleaner, plugin-based suggestions for dealing with this issue?