[LRUG] Reasons for Postgres

Roland Swingler roland.swingler at gmail.com
Tue Nov 17 11:34:28 PST 2009


> - Why I should be using Sequel and what I lose/gain vs ActiveRecord

I've used Sequel for a couple of side projects, and I can tell you
some of the differences:

* Sequel has a concept of a dataset, which you can filter with chained
methods - this is somewhat similar to ActiveRecord's
with_scope/named_scope - you can do more work in ruby and throw around
fewer sql fragments.
* You don't have to use ORM - although Sequel has a Base class similar
to ActiveRecord::Base, you can operate directly on the tables and get
raw hashes back, and use the same style of filtering methods described
above. ActiveRecord's only equivilent is calling execute with a big
fat sql string. This is good if you don't want the overhead of ORM or
object to the concept, but don't want to resort to using raw sql.
* Sequel supports far more database concepts, such as prepared
statements, sharding etc. although I personally haven't needed those
features.
* The API is similar to ActiveRecord's, but a bit fussier - you can't
build up trees of objects and save them all at once for example, and
you can't assign nil to things that can't be null in the database
without setting some configuration - there are probably many other
differences as well.
* Sequel is allegedly faster and has a smaller memory footprint, but I
haven't verified that myself.

Overall Sequel feels closer to the database than ActiveRecord, and
might be a good fit if you have a complicated legacy db to work with
that doesn't fit rails' conventions. It's probably also a good fit if
you just need do to something fast and simple with a database and
don't need the OO mapping. If the lower memory use is true, that would
also make it useful in some situations. Otherwise, you'll probably
find that there isn't enough of a difference between it and
ActiveRecord to make it worth thoroughly learning a new API and
sacrificing the plugins/community, unless you really like the API
style.

HTH,
Roland



More information about the Chat mailing list