I'm working a lot with a VERY large mysql2 database at the moment, and although I have indexed what I thought were the proper fields, the return time for some queries is quite slow.
I have two models that are causing issues, Comment and Commenter.
Now, there is a has_many relationship between Commenter and Comment, but my query relies on finding the each Comment's Commenter's username. So I'll run something like this:
c = Blog.first.comments ##this bit runs fine, I indexed the "blog_id" field on Comments
c.collect {|c| c.commenter.username}
To help with the speed issues, I created an index on the commenter_id field for the Comment model. But it is still running very slow..
Does anybody know of what I could do differently, that would help increase the speed of the query?