How can I stop so many queries from running. With this configuration it generates a few clean queries at the start then a query with 2 inner joins for each tag a line has (so 10 lines means at least 10 queries as each line has at least one tag).
It works, its just very inefficient. I'd appreciate any advice anybody can offer or any resource you could point me to :) Thanks. VIEW %table - @results.each do |line| %tr %td= line.filename -# if I remove the line.tags part then it does NOT generate excess queries, otherwise it generates a query for each tag in each result %td - line.tags.each do |tag| = tag.tagtext CONTROLLER def fetch_results @results = Attachment.all(:attachment_tags => {:tag => Tag.all(:tagtext.like => '%myfile%')} ) end MODELS class AttachmentTag include DataMapper::Resource property :id, Serial belongs_to :attachment belongs_to :tag end class Attachment include DataMapper::Resource after :save, :move_file property :id, Serial property :filename, String has n, :attachment_tags has n, :tags, :through => :attachment_tags ... ... end class Tag include DataMapper::Resource property :id, Serial property :tagtext, String has n, :attachment_tags has n, :attachments, :through => :attachment_tags end -- You received this message because you are subscribed to the Google Groups "DataMapper" group. To post to this group, send email to datamap...@googlegroups.com. To unsubscribe from this group, send email to datamapper+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/datamapper?hl=en.