FAQ
overflow

Great Answers to
Questions About Everything

QUESTION

When I'm running a query for the first time, it takes x miliseconds to be executed. When I run it the second time it takes a lot less time. I assume that it is some caching involved in this mechanism, but I need to know what is the real speed of my queries.

BTW I'm using Apache, MySQL and PHP in Windows (XAMPP).

{ asked by dole doug }

ANSWER

Personally, I tend to use the 2nd and subsequent executions as my benchmark when developing hence this answer...

Arguably the real speed is with caching of data and execution plan.

If it's run often enough to matter, then it will be cached in real life. You are measuring performance the 2nd time. For the first run, you're measuring load/compile times.

On a production server data will be cached too because of use, but on development it won't be.

It it's run once a day or as an occasional report then it doesn't matter (within reason).

{ answered by gbn }
Tweet