For database queries, you have two small problems. Cache: data cache and command cache.
If you run the query once, the statement is parsed, prepared, bound, and executed. Data is extracted from files to the cache.
When you run the query a second time, the cache is used, and performance is often much better.
What is the "real" performance number? First or second? Some people say that the “worst case” is a real number, and we need to optimize it. Others say "typical case" and run the request twice, ignoring the first. Others say "average" and work 30 times, averaging them all. Others say "typical average", work 31 times and average 30 last.
I suggest that "the last 30 of 31" is the most significant number of database performance. Do not sweat that you cannot control (analysis, preparation, binding). Sweat material that you can control - data structures, I / O loading, indexes, etc.
S. Lott
source share