Just wanted to post an update to my previous blog entry about Doctrine ORM gotchas. Since 1.0.4 was released, a seriously limiting bug was fixed in the SoftDelete template. This bug was preventing typical performance optimizations that used LEFT JOINs to reduce the number of database queries. The idea is that a page generally loads much faster by executing few efficient JOIN’ed queries than many single-table queries (do your joins in MySQL, not PHP!)

I had posted a workaround to this bug ($query->addWhere(”deleted = 0 OR deleted IS NULL”) to all of your LEFT JOINs). This was cumbersome and I felt violated the principle of the SoftDelete event listener.

With this bug resolved, I’ve been more freely adding custom finders for specific pages. One page in particular (the MessageBoard thread index) went from 12 seconds to 4 seconds for a very large data set. The number of DB queries also was cut from 1200+ to about 300.

Now I just have to get the page down to 10 queries and we can call it optimized.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Reddit
  • StumbleUpon
, , ,
Trackback

2 comments untill now

  1. Wow, really a perfomance shift!

    I’ve just started messing around with doctrine and each day I god impressed. SoftDelete is an excellent behaviour. I had to code in earlier times to check for active = 1 in my queries, now everything got easier =D.

    I’m working with timestampable, sluggable and searchable. Found a bug on searchable and posted the fix (silly thing) at the forum once, but it is a neat tool indeed.

    [] s

  2. I’ve also ran into a couple bugs in Doctrine which can be time-consuming to locate and fix.

    Still, I prefer Doctrine to writing SQL from scratch–coding models is faster and less error-prone.