How would you expect to navigate an attachment gallery with 300,000 attachments in it? You would need some sort of AI and still a lot of work to build the structure and indices.
A technique I have used on a non-forum site is to allow objects, which may each have many attachments, to belong to an unlimited number of categories/collections. You can then filter for those objects that belong to multiple categories. I think that general approach might work for an attachments gallery, where you could consider each thread an object and use thread tags as categories. You could alternatively use posts for the objects if your thread usage made that work better.