Received: from localhost (unknown [200.46.204.183]) by postgresql.org (Postfix) with ESMTP id 894AA65030C for ; Wed, 30 Jul 2008 22:08:28 -0300 (ADT) Received: from postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 52083-07 for ; Wed, 30 Jul 2008 22:08:19 -0300 (ADT) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 730F76502AF for ; Wed, 30 Jul 2008 22:08:24 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.2/8.14.2) with ESMTP id m6V16c24026509; Wed, 30 Jul 2008 21:06:38 -0400 (EDT) To: Bill Moran cc: tarcizioab@c3sl.ufpr.br, pgsql-performance@postgresql.org Subject: Re: Difference between "Explain analyze" and "\timing" In-reply-to: <20080730205922.ba73b732.wmoran@collaborativefusion.com> References: <50061.201.15.49.76.1217463555.squirrel@webmail.inf.ufpr.br> <20080730205922.ba73b732.wmoran@collaborativefusion.com> Comments: In-reply-to Bill Moran message dated "Wed, 30 Jul 2008 20:59:22 -0400" Date: Wed, 30 Jul 2008 21:06:38 -0400 Message-ID: <26508.1217466398@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200807/263 X-Sequence-Number: 30863 Bill Moran 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