Thread: Difference between "Explain analyze" and "\timing"

Difference between "Explain analyze" and "\timing"

From
tarcizioab@c3sl.ufpr.br
Date:
Hello friends

The commands "\timing" and "EXPLAIN ANALYZE" return values related to the
time of execution of the instruction. These values are "Time:" and "Total
runtime:" respectively. What is the difference between these values, and
the specific use of each command in queries?

If someone can help me.

Thank's for attention.

Tarcizio Bini



Re: Difference between "Explain analyze" and "\timing"

From
Bill Moran
Date:
tarcizioab@c3sl.ufpr.br wrote:
>
> Hello friends
>
> The commands "\timing" and "EXPLAIN ANALYZE" return values related to the
> time of execution of the instruction. These values are "Time:" and "Total
> runtime:" respectively. What is the difference between these values, and
> the specific use of each command in queries?

The time reported by explain will be the time it took the server to
execute the query.

The time reported by \timing is the time it takes the client (psql) to
get the result.  This will be the time the server took, plus any network
delays and time required to process the query and result on the client
side.

--
Bill Moran
Collaborative Fusion Inc.

wmoran@collaborativefusion.com
Phone: 412-422-3463x4023

****************************************************************
IMPORTANT: This message contains confidential information
and is intended only for the individual named. If the reader of
this message is not an intended recipient (or the individual
responsible for the delivery of this message to an intended
recipient), please be advised that any re-use, dissemination,
distribution or copying of this message is prohibited. Please
notify the sender immediately by e-mail if you have received
this e-mail by mistake and delete this e-mail from your system.
E-mail transmission cannot be guaranteed to be secure or
error-free as information could be intercepted, corrupted, lost,
destroyed, arrive late or incomplete, or contain viruses. The
sender therefore does not accept liability for any errors or
omissions in the contents of this message, which arise as a
result of e-mail transmission.
****************************************************************

Re: Difference between "Explain analyze" and "\timing"

From
Tom Lane
Date:
Bill Moran <wmoran@collaborativefusion.com> writes:
> tarcizioab@c3sl.ufpr.br wrote:
>> The commands "\timing" and "EXPLAIN ANALYZE" return values related to the
>> time of execution of the instruction. These values are "Time:" and "Total
>> runtime:" respectively. What is the difference between these values, and
>> the specific use of each command in queries?

> The time reported by explain will be the time it took the server to
> execute the query.

> The time reported by \timing is the time it takes the client (psql) to
> get the result.  This will be the time the server took, plus any network
> delays and time required to process the query and result on the client
> side.

Also realize that explain analyze only reports the time to *execute*
the query.  Not counted are the time to parse and plan the query
beforehand and prepare the explain output afterwards.  But psql's number
is the whole round-trip time and so includes all that stuff.

If any of this seems confusing, you might find it worth reading
this overview of the Postgres system structure:
http://www.postgresql.org/docs/8.3/static/overview.html

            regards, tom lane