[CDBI] Make CDBI go fast
perrin at elem.com
Fri Apr 20 20:59:37 BST 2007
On 4/20/07, Bill Moseley <moseley at hank.org> wrote:
> The database is often cited as the slow point in a web application, so
> that adds weight to these benchmarks.
Or the other way around, actually. It's the database that's the
bottleneck, not the ORM. Two ORMs that generate the same SQL are
going to be pretty similar in most real applications.
The thing is, they don't generate the same SQL. Class::DBI
notoriously does things inefficiently with regard to SQL (joins, bulk
deletes, more fetches than needed sometimes, etc.). You're working
around some of this by using set_sql a lot. You might not have to
> Looking at another, the accessor benchmarks are one thing the I find
> Why the huge difference there?
Class::Accessor, which CDBI uses, is not that fast. It has hooks to
allow overriding. The aptly named Class::Accessor::Fast is much
faster, but kills some of that override capability.
I have seen some people pass ORM objects to TT and call thousands of
accessor methods. This is pretty easy to avoid by passing in hashes
instead, but with a much faster accessor method you might not need to
worry about it.
> Anyone else have any insight on relating the benchmarks to real-world
> web application usage?
Take a look at the SQL that gets run when you hit a page in your CDBI
app. If there's a lot in there that you look at and think "why is it
using 700 SQL calls for that?!" then you will probably do better with
Rose. You also might not have to do as much work with set_sql and
In short, making the SQL efficient is by far the most important thing.
More information about the ClassDBI