Man, you should really take a look at:

http://api.rubyonrails.org/classes/ActiveRecord/Calculations/ClassMethods.html

Cheers, Sazima

On Nov 19, 7:46 am, Günther Lackner <[EMAIL PROTECTED]>
wrote:
> 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 viahttp://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