Interesting from yesterday
The difference between new-style-includes (rails 2.1+) and old-style-includes in rails is the size of the query. In the old style, rails selects all the data from all the tables in a single query, using some crazy renames that look like this:
SELECT users.id AS t1_r1, users.name AS t1_r2, profiles.id AS t2_r1, ... FROM users LEFT OUTER JOIN profiles ON profiles.user_id = users.id
This can get really bad if you :include multiple has_many associations, because the number of rows multiplies rapidly! In the new-style-includes, ActiveRecord does one SELECT per table like so:
SELECT * FROM users SELECT * FROM profiles WHERE user_id IN (1,2,3,4,5,6)
More queries, but each one returns a small number of rows, and overall is a big performance improvement. The problem comes when you add :conditions that reference tables you :include. The new style will attempt to write this query:
SELECT * FROM users WHERE profiles.gender = 'M' # ERROR - no table profiles!
So, you can make all your includes faster as long as you don’t have any :conditions, :order, or :select clauses that select from tables other than the base finder table. In our case, we hardcoded this check to always use the new-style-includes, manually ensuring that we don’t fall into these failing situations.
Ask for Help
“Why does my JVM seg. fault when running SOLR?”
Virtual machines should never segmentation fault! It’s probably a JVM/OS/library issue, so check try a different version of the JVM and check that it has all it’s proper dependencies. Alternatively, try a different VM entirely.
“Is there a way in Excel to ‘reshape’ 2D data?”
If you have an NxM matrix in Excel, you can transpose it to a MxN matrix easily. But if you want to convert it to a (M/2)x(N*2) through a reshaping you’re probably on your own. You could open it in ruby and reshape the arrays that way…