[CDBI] Make CDBI go fast

Bill Moseley moseley at hank.org
Fri Apr 20 14:51:10 BST 2007

On Thu, Feb 15, 2007 at 11:34:36AM -0500, John Siracusa wrote:

> http://rose.sourceforge.net/wiki/index.php/RDBO/Benchmark

It's very hard not to look at those benchmarks and go "wow!", but
I'm not sure how to relate those benchmarks to the web applications
where the different ORMs might be used.

Relating benchmarks to the real world is often difficult, at best.
And probably the only way to know for sure is build a few pages of the
full-blown application and try with different ORMs.  A potentially
expensive process, depending on the application.

The database is often cited as the slow point in a web application, so
that adds weight to these benchmarks.

Still, it seems simple tests using Apache Benchmark on dynamically
built pages (say Cat + TT) without hitting the database is (pulling a
number out of thin air) often around 30 to 40 per second with luck and
then slower on pages if hitting the database hard.  Seems like I was
measuring 15/sec last time I tested a complex page just using ab.

Anyway, here's a random snippet from the benchmark:

    # Simple: insert or update
           Rate CDBS DBIC CDBI RDBO
    CDBS  340/s   -- -18% -22% -76%
    DBIC  412/s  21%   --  -5% -71%
    CDBI  435/s  28%   5%   -- -69%
    RDBO 1413/s 316% 243% 225%   --

Impressive difference for RDBO.  But, I'm not typically doing 1000
inserts in a given request.  One or two, perhaps.  So, then the
difference seems like a small part of the time it takes to do the
entire web request.

Looking at another, the accessor benchmarks are one thing the I find
curious.  Again, a typical single web request doesn't often do 10,000
accessor reads, but that's probably one of the more common tasks.  I
guess those include the fetch, so it's not just accessor timings.

    # Simple: accessor 1
           Rate  CDBS  CDBI  DBIC  RDBO
    CDBS 1.38/s    --   -0%  -11%  -93%
    CDBI 1.38/s    0%    --  -11%  -93%
    DBIC 1.54/s   12%   12%    --  -92%
    RDBO 19.4/s 1308% 1305% 1156%    --

Why the huge difference there?

Anyone else have any insight on relating the benchmarks to real-world
web application usage?

Also, I tend to drop to DBI to do anything complex.  I like how the
ORMs provide object relationships, but I don't expect them to do
everything.  I'm a heavy user of set_sql in CDBI, for example.
I assume that evens the playing field a bit if not depending on the
ORM to do everything.

Bill Moseley
moseley at hank.org

More information about the ClassDBI mailing list