Hello!

I need to speed up a count of apearances of a distinct category of
entities in a table. I get the categories with the following command:

@asset_classes = ActiveRecord::Base.connection.select_values "SELECT
DISTINCT CLASS FROM SymbolsMatch_MASTER ORDER BY CLASS"

Now I need to create a list of this categories together with the number
of apearance in the table. Momentarily I use this syntax but it is VERY
slow.





<ul>
 <% for asset_class in @asset_classes do %>
 <%  count = DeviceToUpdate.find(:all, :conditions => ["status like
'moreinfo' and CLIENT_STATUS is NULL and CLASS like ?",asset_class ]
).count
        if count > 0 %>
  <li>
   <a href="<%= url_for(:controller => :more_info, :action =>
:show_class, :class_name => asset_class) %>"><%= truncate(asset_class,
20, ".") %>  (<%= count.to_s %>)</a>
        </li>
  <% end %>
 <% end %>
</ul>





Thank you for any suggestion how to speed this up!

lacky
-- 
Posted via http://www.ruby-forum.com/.

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to