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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Bill Moran <wmoran(at)collaborativefusion(dot)com>
Cc: tarcizioab(at)c3sl(dot)ufpr(dot)br, pgsql-performance(at)postgresql(dot)org
Subject: Re: Difference between "Explain analyze" and "\timing"
Date: 2008-07-31 01:06:38
Message-ID: 26508.1217466398@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-performance

Bill Moran <wmoran(at)collaborativefusion(dot)com> writes:
> tarcizioab(at)c3sl(dot)ufpr(dot)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

In response to

Browse pgsql-performance by date

  From Date Subject
Next Message Miernik 2008-07-31 02:45:08 why "WHERE uid NOT IN" is so slow, and EXCEPT in the same situtation is fast?
Previous Message Bill Moran 2008-07-31 00:59:22 Re: Difference between "Explain analyze" and "\timing"