We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Phalcon/Db/Adapter/Pdo->__construct slow?

Hi,

I would like to ask you if it's normal for "Phalcon/Db/Adapter/Pdo->__construct" to take 1 second? When I check this forum with Firebug, waiting time is 240ms, so I guess 1 second is too long for the PDO.

The measurement is made on wampserver.

Best regards.



98.9k
Accepted
answer

Phalcon/Db/Adapter/Pdo->__construct is not slow itself but connecting to a database is, try changing localhost by 127.0.0.1

edited May '14

Thank you for your answer. Same speed with 127.0.0.1, but if it's a problem with my local pc is not that important, the thing is that when uploaded on hosting it takes same time to wait.

phalcon.so is on Bluehost shared hosting loaded thru custom php.ini (mod_suphp.c in .htaccess). If this can effect database connection speed.


I guess I misunderstood. The speed was the same when I enter 127.0.0.1 instead localhost in the browser. When I changed it in the bootstrap file it worked! Phalcon is great! I tryed it in ubuntu too and is very fast!

For Bluehost it didn't worked though. It's still slow. Could the reason be that phalcon.so is precompiled and then uploaded on the server?

Regarding shared hosting issue I found this: https://forum.phalcon.io/discussion/929/phalcon-on-shared-hosting. It worked reducing waiting to 400 - 500 ms. I guess using VPS will give better results. Great.