I have such models structure:
class Entity < ActiveRecord::Base
habtm :properties_1
# ...
habtm :properties_N
end
I need to write request by any set of properties, it causes N joins:
Entity.joins(:properties_1, :properties_N).where("properties_1.id = ? AND properties.N = ?", p1_id, pN_id)
N may be > 20
What can I use to increase query performance?
I think about caching all this settings to big table with serialized attributes, but it looks like this problem is common and, probably, any existed solution is present.
Any ideas?
Thanks for advance!