1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

XF 1.2 Query count higher on debug page than in footer?

Discussion in 'Troubleshooting and Problems' started by alexp999, Jan 7, 2014.

  1. alexp999

    alexp999 Active Member

    I am just in the process of trying to make my site as lean as possible before it goes live, so I have enabled debug mode to try and see if there are any extra queries I could reduce and I have noticed that on say the forum index, the footer will say 10 queries, but when you click on it, the debug page says there are 14.

    Any idea why the debug page would show more queries?
  2. Mike

    Mike XenForo Developer Staff Member

    It is possible to run queries after the total is calculated on the full-page output.
    alexp999 likes this.
  3. xf_phantom

    xf_phantom Well-Known Member

    The debug query count is being fetched and set to the template, BEFORE all operations are finished.
    All the events executed after calling $template->setParams(XenForo_Debug::getDebugTemplateParams()); won't be counted to the query count :(.

    If you want the REAL query count, you need to call XenForo_Application::getDb()->getProfiler()->getTotalNumQueries(); as LAST operation, just before the response is being sent to the client and output the phrase (I'm using an event listener on front_controller_post_view to get the REAL query count)
        public static function frontControllerPostView(XenForo_FrontController $fc, &$output){

            if (
    $fc->getDependencies() instanceof XenForo_Dependencies_Public){
    $search '$STATUSCODE$';
    $code $fc->getResponse()->getHttpResponseCode();

    $color 'green';
                switch (
    $color 'red';
    $allQueries XenForo_Application::getDb()->getProfiler()->getTotalNumQueries();
    $output str_replace('$ALLQUERIES$'$allQueries$output);
    $output str_replace('$STATUSCOLOR$',$color,$output);
    $output str_replace($search,$code,$output);
    Last edited: Jan 7, 2014
    alexp999 likes this.
  4. alexp999

    alexp999 Active Member

    Thanks for the quick replies, so I assume the debug page should be correct, it is the footer count which is "wrong"?

Share This Page