Well, one has to ask... is ActiveRecord the be all and end all of ORM frameworks? And anyway, why not? But to the point:
* Sequel is designed to be thread-safe. AR has a bit of a problem in this respect. If you're not aware of the whole problem of Rails and MT do a Google search and you'll see what I mean.
* Sequel also offers a connection pool for multi-threaded apps. AR doesn't.
* In Sequel it's much easier to work with multiple records. Unlike AR, Sequel doesn't load all records from a query into memory but rather provides you with an Enumerable interface to the records. Thus you can work with very large result sets containing millions of records without bringing your machine down.
* Sequel doesn't make you use Model classes. You can fetch records as hashes with column names as keys and column values as values. If you're interested in a single column you can get it as an array. If you're interested in two columns you can get it as a hash with one column as the key and the other as the value. Or you can use any of the Enumerable methods (reject, inject, etc.) to manipulate the result set.
* Sequel models offer memcached functionality out of the box. In AR you have to use a plugin for that.
* Sequel datasets make working with data sets really easy, e.g.:
my_posts = DB[:posts].filter(:user_id => 1234).descending_order(:stamp)
puts my_posts.count
last_20_titles = my_posts.limit(20).map(:title)
# let's analyze this query
puts my_posts.analyze
Now look at all the things I'm not doing!
I'm not defining a model class.
I'm not writing SQL.
I'm not downloading any acts_as_fill_in_the_blank plugin from the internet.
* Sequel does not yet provide the level of relationship support that AR provides with has_one, has_many etc., but it already provides the basics, and I believe will at some point offer superior functionality in that department.
And one last, very important difference:
* Sequel is lightweight, and will remain so. AR is, to put it mildly, a big and complex beast. Sequel is fast. AR is slow. And you STILL are probably going to download a bunch of plugins to get it to do what you need.
I hope that answers your question.
|