I have an application where a particular table has_many other records. (reader_device has_many deliveries). If I try to display the association in the AS page, the page can take 23 seconds or longer to load. If I just take that association out of the columns, the same page takes less than a second to load.
I think the problem is not determining the count of the has_many relationship. I've done indexes on the foreign_keys etc. It seems that the scaffold is iterating through all the thousands of records do build the link. There is something missing in the log file since the rails log shows: Completed in 21563ms (View: 575, DB: 23) | 200 OK [http://localhost/ reader_devices] So only 23 msec in the db and 575 in the view. Where is the other 21000msec? If I just remove the deliveries column from the controller config, the same page takes: Completed in 403ms (View: 364, DB: 17) | 200 OK [http://localhost/ reader_devices] I tried creating an attr on the model called delivery_count that just did deliveries.count and the page loads fast again. This happens everywhere in my application where I have an association with a lot of data in the association. Has anybody else run into this? Please don't tell me to go optimize the SQL. There is something fishy in ActiveScaffold going on here. It seems that in order to build the text of the link in the table, it's doing something like: #<Delivery:0x7f0c60d1a880>, #<Delivery:0x7f0c60d18490>, #<Delivery: 0x7f0c60d15470>, … (1713) which makes me think it's loading every single delivery of that 1713 just to build the text for this link. The SQL to count those 1713 records is fast. Anybody else hit this and solve it? Mike Vargo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "ActiveScaffold : Ruby on Rails plugin" 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/activescaffold?hl=en -~----------~----~----~----~------~----~------~--~---
