Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have a setup for connecting to a postgresql database the works like this:

  1. Apache
  2. PHP pg_connect
  3. prepared_statement
  4. ip address to server
  5. pg_bouncer
  6. unix socket
  7. return queried data

When I return the query without PHP it takes 900 milliseconds to execute, or .9 seconds. But the page load with the query takes 4 seconds to load, so that is around 3 seconds in connection. I'm using Rackspace as my hosting so its not the connection speed. How can I improve the performance of PHP connecting to to the database database server?

share|improve this question
 
are both your database and php server hosted by Rackspace ? –  Maximus2012 Aug 6 at 13:34
 
could it be some static elements like js/css/images on your page that are taking more time to load ? Is your code referring to some external elements on a different domain that could be slowing things down ? –  Maximus2012 Aug 6 at 13:35
 
Yes they are, and I use the private ip to connect –  Devin Dixon Aug 6 at 13:35
1  
If your query is running fast without PHP so I doubt its the database that is the issue. Did you profile your page using network tab in tools like firebug or chrome/ie developer ? –  Maximus2012 Aug 6 at 13:36
 
No, I'm not measuring js/css/images, just how long it takes to output the data from the database. –  Devin Dixon Aug 6 at 13:36
show 7 more comments

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.