geoB
geoB

Reputation: 4704

First run of script process time

In an admin application for the local food bank, I've built a PHP script to generate a set of monthly reporting statistics from a MySQL database. It appears that if the script has not been run for some uncertain amount of time it will take several seconds to run. Once run, subsequent runs of the script will take a fraction of a second. I'm trying to figure out what factors cause the lengthy first run and whether I have any control of them. The behavior is comparable between my development system and the food bank's host so it's not just a local phenomenon.

I've experimented with "flush tables" and "reset query cache" but I cannot reproduce the long run. Nor does shutting down and restarting the MySQL server (only possible on the development system) make the run longer.

Where else might I look?

Thanks.

Upvotes: 1

Views: 132

Answers (1)

liquorvicar
liquorvicar

Reputation: 6106

My first port of call in circumstances like this would be to profile the script to see what's taking the time. You say you can replicate the problem locally. In that case get yourself a profiler (xDebug and the Zend Debugger can both profile scripts, there may be others) and profile your script to see where the time is going.

Upvotes: 1

Related Questions