Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Whip Me, Beat Me, Make Me Use ORMs

by lima1 (Curate)
on Jun 29, 2007 at 13:32 UTC ( [id://624090]=note: print w/replies, xml ) Need Help??


in reply to Whip Me, Beat Me, Make Me Use ORMs

If fact, when would you choose to use or not use an ORM?

The obvious: I would think twice if I should use an ORM when performance is REALLY critical. Maybe some tutorials on how to profile queries and improve the performance would be nice. In my (humble) experience, this isn't that trivial...

Replies are listed 'Best First'.
Re^2: Whip Me, Beat Me, Make Me Use ORMs
by merlyn (Sage) on Jun 29, 2007 at 15:07 UTC
    A decently fast ORM like Rose::DB::Object probably wouldn't be noticable for most of the accesses. For the critical ones, you could push the queries down directly as handwritten SQL using the same database handle, so RDBO gets out of the way when you need it (as do other ORMs).
Re^2: Whip Me, Beat Me, Make Me Use ORMs
by Ovid (Cardinal) on Jun 29, 2007 at 15:36 UTC

    merlyn is right. Rose is wicked fast. It's fast enough that you're unlikely to notice too much of a difference and it's easy to fine-tune, if needed. The wins with Rose (and its clean design), easily outweigh the losses.

    You can see the benchmarks for yourself.

    Cheers,
    Ovid

    New address of my CGI Course.

      When you work with many tables and gigabytes of data, you have to fine-tune many queries. The last time I had these problems, this tuning was not that easy because an ORM is kind of a blackbox - RDO probably less than others. I ended up with ugly code that was not more maintainable than plain DBI code. Well, probably I am someone who does silly things with ORMs ;)

      But I really like RDO, so I'd interested in reading more about things you should consider (probably starting with the db schema) when you go beyond little webapp databases ;)

        You're correct: complicated queries on large databases are no place for an ORM. Rose is pretty fast for simple-to-medium queries, but complex ones always require hand-tweaked SQL. You can run hand-written SQL through Rose though (or others), and it can still provide a convenient place to organize your custom queries and deal with your database handle/statement caching.

        I would also add that ORMs are never good for bulk updates. You can totally crush the speed of an ORM for a bulk insert/update by writing some simple DBI code or by using your database's bulk loading features, e.g. multi-row insert in MySQL.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://624090]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-26 03:31 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found