SqlSessionStore gains support for SQLite
Posted 09 Nov 2006
Ted X Toth has submitted the code for a SQLite session class implementation for SqlSessionStore. I have checked it into the subversion repository.
Thank you very much Ted!
Posted 09 Nov 2006
Ted X Toth has submitted the code for a SQLite session class implementation for SqlSessionStore. I have checked it into the subversion repository.
Thank you very much Ted!
Posted 05 Oct 2006
During the preparation of my RailsConf2006 talk I did some comparative benchmarks with Mysql and Postgresql. To my astonishment, I observed that Rails with Mysql created many more objects. After digging into the C part of ruby bindings of Mysql, I discovered that the Mysql bindings create a copy of the columns name string for each record retrieved from the database. This obviously leads to quadratic memory use and calls for correction.
I’ve written a small patch for the ruby-mysql bindings and submitted it to the author, but never got a response, although a tried several times.
You can get the patch here.
The patch actually goes a little farther than just correcting the n*m problem. I have added a Mysql::Result.all_hashes method, so that the entire array of hashes creation runs in C.
For pages that retrieve small datasets, you will probably see only a small increase. I measured around 5% increase for pages that load 25 objects. Which is neat. But the patch really shines when you retrieve large data sets. For example, for loading 1000 objects, I got this perf data:
page | c1 total | c2 total | c1 r/s | c2 r/s | c1 ms/r | c2 ms/r | c1/c2 |
---|---|---|---|---|---|---|---|
/alphabetic | 6.86126 | 5.20610 | 14.6 | 19.2 | 68.61 | 52.06 | 1.32 |
GC statistics | c1 total | c2 total | c1 #gc | c2 #gc | c1 gc% | c2 #gc% | c1/c2 |
2.14250 | 1.18728 | 24.0 | 12.0 | 31.23 | 22.81 | 2.00 |
30% faster!
But more important, a lot less gargabe gets created (in the example GC runs twice as often with the unpatched bindings).
You can take advantage of this by creating your own garbage ;-)
Posted 05 Oct 2006
Due to a contribution from Tiago Macedo, sql_session_store has gained Oracle support.
If you’re on Oracle and want improved session handling performance, you should give it a try.
If you find any problems, please submit bug reports/patches here.
And if you now how to and have time to implement support for other database adapters, please send an email or better, create a ticket and attach the patch.
Posted 23 Sep 2006
I’ve added another plugin for you to check out: query_builder.
This plugin enables you to define finder methods that bypass the overhead of construct_finder_sql.
Inside an ActiveRecord model definition, define_finder query_name, query_type, options_hash
class Recipe
define_finder :find_all_of_user, :all,
:conditions => 'user = :user AND priv < :priv'
end
Recipe.find_all_of_user :user => 'martin', :priv => 1
Recipe.find :all, :conditions =>
[ 'user = :user AND priv < :priv',
{:user => 'martin', :priv => 1} ]
define_finder :find_all_of_user, :all,
:conditions => 'user = :user AND priv < :priv',
:positional => true
Recipes.find_all_of_user('martin', 1)
I converted one of my pages to use this style and it gained 10% more performance.
If you like this plugin, drop me a line. If you find a bug, please submit a bug report to Trac
Enjoy.
Posted 16 Sep 2006
Timo Hentschel, one of my coworkers at the company for which I’m doing contract work at the moment (AutoScout24), has added a nifty little extension to my piggy_back plugin.
It’s now possible to piggy back from has_many :through associations, provided the association will return at most one record from the underlying SQL query.
This type of association currently needs to be used as a replacement for the non existent has_one :through.
There have been rumours that has_one :through will find it’s way into rails core. If it does, I’ll probably remove the has_many :through support from piggy back plugin again, or at least raise a deprecation warning.