how to find what is taking so long on a form submission? php/mysql

Joined
12 Feb 2006
Posts
17,382
Location
Surrey
i have a form that when submitted, works out a total, saves the input information to a mysql database, emails a copy and then displays the quote to the user.

this can sometimes take a good 10 seconds to do when it's the first time done. if i go back edit the quote and click submit then it can be instant.

i suspect the slow down is coming from mysql, only because it's at this point that the database connection is first opened, and then from then on it's been opened once i guess the second time isn't so slow, but this is just a gut feeling.

any suggestions as to how you'd go about finding out what is slow?

this is written in php/mysql
 
How many forms have been submitted?

Only real way to do this is to profile... can you pull the SQL out it's running and manually execute?

This way you can find out how quick an insert is, how quick a retrieval is... if there are no indexes, and this system has been up for a long time, you may have excessive read times.
 
i have a form that when submitted, works out a total, saves the input information to a mysql database, emails a copy and then displays the quote to the user.

this can sometimes take a good 10 seconds to do when it's the first time done. if i go back edit the quote and click submit then it can be instant.

i suspect the slow down is coming from mysql, only because it's at this point that the database connection is first opened, and then from then on it's been opened once i guess the second time isn't so slow, but this is just a gut feeling.

any suggestions as to how you'd go about finding out what is slow?

this is written in php/mysql
you could do the MYSQL directly as above or use this to print how long each function or part of your code takes thus finding out the slowest part?

$time_start = microtime(true);
sleep(1);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Process Time: {$time}";
 
Back
Top Bottom