views:

54

answers:

3

How you will handle complicated web page where you must display one User account with a lot of relations (15+)

The translation data is kept on separate tables (globalize2/3) so the queries rised to 30+.

Putting the ACL and some logging and you will got 45+ queries sometimes 65+

I don't want to split the page on multiple screens all data is required on one screen.

Currently I have pre-loaded all the relational tables for the User in a global variable in the Rails and it works fine except it is complicated to maintain the cache with all the sync and translation data.

I have tried memcached but it was slow because each object has to be serialized/de-serialized on every request.

What is the best way to handle such page(s)?

+3  A: 

If you have a single model with a bunch of relationships, eager loading with "include" should help you significantly. In Rails 2.3 It works something like:

User.find(1, :include => [:relationship1, :relationship2, :relationship2])
Beerlington
A: 
quest
I would be cautious when doing eager loading with this much nesting. Sometimes overly complex joins can actually slow things down. I would highly recommend doing some benchmarking in these cases because it's difficult to say when you're doing too much.
Beerlington
My example was for completeness, not necessarily best practice. I completely agree that benchmarking is always a good idea.
quest
The question is how to not load those "includes", but reuse them. Your list of cities, countries, property types, offer status etc.. is aways the same and there is no need to make queries on every page for those.
Ivailo Bardarov
A: 

Another way might be to store the collections under the client browser

http://www.gudasoft.com/english/development/rails-development/10/28/1342/store-data-in-the-browser-with-rails-and-jquery/2010

Ivailo Bardarov