|From:||Mathieu Dubois <mathieu(dot)dubois(at)limsi(dot)fr>|
|To:||Josh Kupershmidt <schmiddy(at)gmail(dot)com>|
|Subject:||Re: What does \timing measure?|
|Views:||Raw Message | Whole Thread | Download mbox | Resend email|
On 04/08/2011 05:04 AM, Josh Kupershmidt wrote:
> On Thu, Apr 7, 2011 at 3:52 PM, Mathieu Dubois<mathieu(dot)dubois(at)limsi(dot)fr> wrote:
>> I want to compare the time needed to execute 2 queries (which give the same
>> Of course this depends on the server load, the network, etc.
>> The basic idea is to use "\timing on" under psql but what is the returned
>> time? The time to execute the query on the server or the time to fetch the
> The \timing command will show you the total time it took to execute
> your query, and fetch the results back to the client.
>> In the first case the measurement would be more useful (no effect of the
>> network and the client side).
> Try EXPLAIN ANALYZE instead, which will show you (among other things)
> the total time to execute your query on the server, not including the
> overhead of fetching results.
Thanks! Just for the record I point to the manual page explaining it:
"The ANALYZE option causes the statement to be actually executed, not
only planned. The total elapsed time expended within each plan node (in
milliseconds) and total number of rows it actually returned are added to
the display. This is useful for seeing whether the planner's estimates
are close to reality."
So EXPLAIN ANALYZE is really the solution to my problem (measuring time
on the server).
>> I have also a methodological question.
>> The idea is to measure several times the same query (let's say 50 times) to
>> get basic statistics.
>> If I repeat the same query 50 times will the server use some caching
>> mechanism to accelerate the query? In my case, this is not wanted (because I
>> want to measure the normal query time).
> Both PostgreSQL and your operating system will cache recently-accessed
> blocks of data, so you will often see subsequent executions of the
> same query be quicker than the first. If you're really only interested
> in the performance of your query without the help of caching, you can
> restart PostgreSQL plus clear out your OS's filesystem cache between
> each run.
Yes I'm really interested in the "cold query time".
Is restarting PostgreSQL mandatory? What about just log out (from
PostgreSQL), wait some time (let's say 1mn) and then relog?
Also a quick googling shows that to clear OS cache I can run (on the
sysctrl -w vm.drop_caches=3;
Is that right?
Thank you very much for your time (and my \timing :).
|Next Message||Josh Kupershmidt||2011-04-08 13:02:37||Re: What does \timing measure?|
|Previous Message||Josh Kupershmidt||2011-04-08 03:44:14||Re: Valid role name (PostgreSQL 9.0.4)|