Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8572607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T19:03:32+00:00 2026-06-11T19:03:32+00:00

Im developing a front end for a site where performance is very important. Rapid

  • 0

Im developing a front end for a site where performance is very important. Rapid development was also key, so I made the decision to go with symfony2 and to use the Doctrine2 ORM.

When I request a simple page from symfony (without DB request) it responds in ~200ms. As soon as I request anything from the DB through Doctrine it jumps up to ~1300ms.

I appreciate there is time to hydrade the records, but this is with me hydrating to array.

Heres the controller code. The template just outputs the array count.

$repository = $this->getDoctrine()->getManager()->getRepository('AcmeProductBundle:Product');
    $qb = $repository->createQueryBuilder('g');
    $qb->addOrderBy('g.id', 'DESC');

    $ret = null;
    $query = $qb->getQuery();
    //$query->useResultCache(true, 3600);
    $ret = $query->getArrayResult();
    return $this->render('AcmeCatalogBundle::test.html.twig', array('id' => count($ret)));

Looking at the Timline in symfony profiler toolbar, the contoller is taking ~1000ms and doctrine is taking ~1ms. But if i comment out the getResults() line the controller jumps down to ~45ms.

Is this normal? What can I do about this?

UPDATE
I ran the following test and it shows that the first query is where all the time is lost:

$ret = array();
    $start = microtime(true);
    for ($i = 1; $i <= 10; $i++) {
        $time_start = microtime(true);

        $query = $em->createQuery('SELECT p FROM AcmeProductBundle:Product p WHERE p.id = 1');
        $products = $query->getResult();

        $time_end = microtime(true);
        $ret[$i] = $time_end - $time_start;
    }
    $end = microtime(true);
    $ret['Total'] = $end - $start;

    return $this->render('AcmeCatalogBundle::test.html.twig', array('ret' => $ret));

And the results:

  1. 1.0216779708862
  2. 0.00091791152954102
  3. 0.00082588195800781
  4. 0.00081419944763184
  5. 0.00081706047058105
  6. 0.00081610679626465
  7. 0.00081491470336914
  8. 0.00081706047058105
  9. 0.00043296813964844
  10. 0.0004270076751709

Total – 1.0283808708191

Could it be that the db connection or entity manager isnt being pooled perhaps?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T19:03:34+00:00Added an answer on June 11, 2026 at 7:03 pm

    So as you guys suggested, it turned out to be my environment. Namely, that I was using ‘localhost’ as the database_host in symfony. Changing it to ‘127.0.0.1’ made all the difference. Im now running queries suitably fast.

    Thanks for your comments people.

    http://www.bluetopazgames.com/uncategorized/php-mysql_connect-is-slow-1-second-for-localhost-windows-7/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm developing chat application. I use flash as front end and asp.net back-end. My
I'm developing a web app. MySql/PHP back-end, and HTML/jQuery front-end. I wanted to use
Hi I am developing a site with JSP/Servlets running on Tomcat for the front-end
I am developing the front end site for a coupon company, and I have
I'm developing a web app (A) that serves as a front-end to another website
I am interested in developing a front end to an existing database that could
I'm developing a front-end to a Rails application. In cross-browser testing, I immediately discovered
I'm developing an app with a Flex-based front end and a Spring/Hibernate back-end. To
I am developing in Visual Studio and am making a lot of front-end changes
I am developing a very simple CMS system for my brother's web site. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.