Rails Progress

All my models are implemented in Rails and I wanted to give a quick update on how things are going.
  • For now, I'm been using the rails views and controllers to test my code (automated tests coming soon). This has worked out great for me. Since my application only allows users to view and filter database records, I don't have a lot of validation checks, but I wanted to get a feel for the performance of pages need to display a lot of data from various tables. One page I tested performs 35 queries (including all the counts and show field commands) and takes about 5 seconds using the Webrick server (from NetBeans so I believe JRuby is being used). The development log lists the time spent in the database as less than 1 second. I'm sure performance could be better, but this is a big improvement over what we had before and the database I'm using contains more records.
  • I'm still noticing that when you ":include" more than one model in a "find" command, more than 1 query is performed. The authors don't mention this in Agile Web Development with Rails so I'm wondering if I have something wrong or if this is a performance enhancement??? Here is a snippet...
         @mp_events = Model.find :all,
    :include => [{:model_data1 =>
    [:nested_data1, :nested_data2]},
    :model_data2],
    :conditions => query
    Something cool about this statement, "nested_data1" and "nested_data2" eager load data connected to Model through "model_data1". This works great! I found the information about nested includes here. This author claims a single query as well. I'm wondering if my extra "conditions" clause triggers Ruby to produce the extra query.
  • One bummer about ":include" is that it does not seem to work with the nested ":select" option. I wanted to total a few of the columns where data was grouped and couldn't get it to work. I resorted to "find_by_sql".

We're now talking about exposing access to these models through a web service. I also need to test more queries with more complex criteria. I'll continue to post interesting tidbits as I encounter them.

Comments

Popular posts from this blog

I Believe...

FRail :include

Performance Tuning JCAPS - Part 2