Added query micro-optimization

This adds a micro-optimization to the query and also exposes better the function calls to the profilers like XDebug or XHProf.