Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1eBicp-0006Vj-H0 for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Nov 2017 14:43:43 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.84_2) (envelope-from ) id 1eBico-000846-Vl for pgsql-bugs@arkaria.postgresql.org; Mon, 06 Nov 2017 14:43:43 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eBico-00083w-FH for pgsql-bugs@postgresql.org; Mon, 06 Nov 2017 14:43:42 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1eBicm-0007ns-2S for pgsql-bugs@postgresql.org; Mon, 06 Nov 2017 14:43:41 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.14.4/8.14.4) with ESMTP id vA6EhcGU010069; Mon, 6 Nov 2017 09:43:38 -0500 From: Tom Lane To: David Rowley cc: mahmoud alorfaly , PostgreSQL mailing lists Subject: Re: BUG #14889: explain analyze is taking much more time than actual execution In-reply-to: References: <20171106065021.1492.80384@wrigleys.postgresql.org> Comments: In-reply-to David Rowley message dated "Mon, 06 Nov 2017 21:08:59 +1300" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <10067.1509979418.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Mon, 06 Nov 2017 09:43:38 -0500 Message-ID: <10068.1509979418@sss.pgh.pa.us> List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org David Rowley writes: > On 6 November 2017 at 21:04, mahmoud alorfaly > wrote: >> With EXPLAIN (ANALYZE, TIMING OFF), it is back to normal execution speed. > Then it's just the TIMING overhead that's causing the slowdown. This > will vary depending on how long gettimeofday() takes on your system. > This is known to be an overhead which is one of the reasons the TIMING > OFF option exists. The size of the overhead in this case implies that gettimeofday() is doing a kernel call, which I wouldn't really have expected on any modern Linux kernel. What hardware is this on? Is there virtualization involved? For context, on RHEL6 on run-of-the-mill server iron, I get overheads more like this: regression=3D# explain analyze select i from generate_series(1,10000000) i; QUERY PLAN=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20 ---------------------------------------------------------------------------= ------------------------------------------------------ Function Scan on generate_series i (cost=3D0.00..10.00 rows=3D1000 width= =3D4) (actual time=3D1711.319..3083.864 rows=3D10000000 loops=3D1) Planning time: 0.078 ms Execution time: 3636.962 ms (3 rows) regression=3D# explain (analyze, timing off) select i from generate_series(= 1,10000000) i; QUERY PLAN=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20 ---------------------------------------------------------------------------= ------------------------------ Function Scan on generate_series i (cost=3D0.00..10.00 rows=3D1000 width= =3D4) (actual rows=3D10000000 loops=3D1) Planning time: 0.077 ms Execution time: 2870.410 ms (3 rows) regards, tom lane --=20 Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs