Re: [CDBI] Make CDBI go fast
"Perrin Harkins" <[email protected]> Fri, 20 Apr 2007 15:59:37 -0400
| Newsgroups | gmane.comp.lang.perl.modules.class-dbi |
|---|---|
| Message-ID | <[email protected]> |
On 4/20/07, Bill Moseley <[email protected]> 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 with Rose. > Looking at another, the accessor benchmarks are one thing the I find > curious. [...] > 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 friends. In short, making the SQL efficient is by far the most important thing. - Perrin