I'm currently building a web application using Zend framework 1.11.11 and Doctrine 2.2. I searched a lot for the best ways and hacks to optimize the frameworks used.
During my search for Zend framework optimization I stumbled upon this post: Optimising the Zend Framework
What was interesting about it is that it mentioned few optimization techniques that emerged from the usage of the framework itself and wasn't covered in the manual itself such as:
Now I'm looking for similar techniques that could be applied to Doctrine 2 other than the ones mentioned here in the manual.
Note
I know many will mention profiling the queries, caching and finding the bottle neck of the app, but that's not um looking for :) I am looking for practical enhancements discovered during Doctrine 2 usage.
Thanks ;)
Well, optimizing and hacking Doctrine 2 will not be an easy task. I can only advise you to follow the official "best practice":
(Note that I didn't mentioned Result cache which should not be a way to optimize an application)
From my use, the most important part I had to optimize was not Doctrine itself (while there are optimizations to do to the core) but the generated Query, as always, I EXPLAIN
ed the queries and optimized indexes.
Doctrine 2 can be high memory consuming so loading a lot of entities at once may slow down your application, you may find it useful to known about clear()
, detach()
, iterate()
methods.
Despite the fact Doctrine 2 can sometimes be slow, I mostly noticed that I was able to optimize application somewhere else, within the Zend Framework or PHP themselves.
Let's say, Doctrine 2 takes 100ms where Zend Framework takes 300ms for a total of 450ms (I/O stuffs, PHP internal functions, etc..)
If you can divide easily by two the time taken by Zend Framework, optimizing Doctrine 2 to gain like 10% will not increase notably the speed of your application. Think about it twice.
Here are a few tips:
There are tons of optimization to do, some have a real impact while others don't.
Make sure to find them by profiling your application, an easy and cross-platform is to use webgrind.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With