I need help to optimize a query (sort of ...) if params[:debit] == "on" @schools = School.find(:all, :conditions => ["name like ?", "%#{params[:search]}%"], :order => ''name'') @schools.delete_if { |s| s.debit <= 0 } @school_pages = Paginator.new self, @schools.length, 20 The problem here is that instance.debit is a virtual attribute ... Any clue ? ngw --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, could you explain what issues you''re seeing? Have you performed any timing tests with script/console? -Conrad On 1/6/07, Nicholas Wieland <nicholas.wieland-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I need help to optimize a query (sort of ...) > > if params[:debit] == "on" > @schools = School.find(:all, > :conditions => ["name like ?", "%#{params[:search]}%"], > :order => ''name'') > @schools.delete_if { |s| s.debit <= 0 } > @school_pages = Paginator.new self, @schools.length, 20 > > The problem here is that instance.debit is a virtual attribute ... > > Any clue ? > > ngw > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Il giorno 06/gen/07, alle ore 20:01, Conrad Taylor ha scritto:> > Hi, could you explain what issues you''re seeing? Have you performed > any timing tests with script/console?Well, it''s damn slow ... more than 1 minute to complete. ngw --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hey, On 6-Jan-07, at 10:29 AM, Nicholas Wieland wrote:> > I need help to optimize a query (sort of ...) > > if params[:debit] == "on" > @schools = School.find(:all, > :conditions => ["name like ?", "%#{params[:search]}%"], > :order => ''name'') > @schools.delete_if { |s| s.debit <= 0 } > @school_pages = Paginator.new self, @schools.length, 20 > > The problem here is that instance.debit is a virtual attribute ... >If you''re concluding that instance.debit is an attribute which cannot be calculated in an SQL query then you''ve got limited options. Your first course of action would be to ensure there really isn''t some way to have the ''debit'' attribute calculated in SQL - find an expert with more knowledge/experience to help you. After that, if it looks like SQL really isn''t an option (or is so ugly and clunky that you lose sleep over it), look at caching the ruby-computed value of ''debit'' in the schools table. Regards, Trevor> Any clue ? > > ngw > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---