Jump to content


Photo

bad PHP/MySQL code or slow server?


  • Please log in to reply
2 replies to this topic

#1 stone140

stone140
  • New Members
  • Pip
  • Newbie
  • 3 posts

Posted 16 October 2006 - 03:45 PM

Hi - You all really helped me out last time but I have a question that hopefully someone can help me out with.

Which is the most likely case for my problem.

When going to my site it takes forever to load.  Once you are able to finally get in you can roam around the site without too much of a problem but its still slow.  When traffic is low you can get in but again, its slow.  I wrote the php / mysql code myself (i'm no professional) and i subcribe to DreamHost and have their basic plan.  It says i get 80 gigs of bandwidth a month.  Is it possible that they limit the amount able to be transfered at once or just that my coding sucks.  In my site I pull images from a server and pull items from my mysql database.  (usually only 1 or 2 queries a page). 

#2 neoform

neoform
  • Members
  • PipPipPip
  • Advanced Member
  • 241 posts
  • LocationMontreal

Posted 16 October 2006 - 03:48 PM

unless you've got some heavy sql queries with large databases and joins, it's your host that's slow.
Newsique.com Social News Network

#3 xsist10

xsist10
  • Members
  • PipPipPip
  • Advanced Member
  • 114 posts

Posted 16 October 2006 - 04:02 PM

Are the images on a remote server to the site? Not clear in your explaination.

Slow-downs can be a number of things. The best way to test is to see who long your script takes to execute. Do this like so (stolen from www.php.net/microtime):

Put this at the beginning of your code:
<?php

// If you have PHP 5
$start = microtime(true);

// else
function microtime_float() {
   list($usec, $sec) = explode(" ", microtime());
   return ((float)$usec + (float)$sec);
}

$start = microtime_float();

?>

Put this at the end of your code:
<?php

// If you have PHP 5
$time_taken = microtime(true) - $start;

// else
$time_taken = microtime_float() - $start;

echo "Time to execute script: ". $time_taken;

?>


You'll probably find that the server is slow in delivering the page if the time it takes to execute the page is less than 0.2 seconds.
SA PHP Archives - www.phparchives.za.org




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users