Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fVdiU-0002wm-EL for pgsql-general@arkaria.postgresql.org; Wed, 20 Jun 2018 14:04:10 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fVdiR-00063d-VH for pgsql-general@arkaria.postgresql.org; Wed, 20 Jun 2018 14:04:07 +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.89) (envelope-from ) id 1fVdiR-00063P-Ja for pgsql-general@lists.postgresql.org; Wed, 20 Jun 2018 14:04:07 +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.89) (envelope-from ) id 1fVdiO-0000V1-Tf for pgsql-general@lists.postgresql.org; Wed, 20 Jun 2018 14:04:06 +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 w5KE3sWf007417; Wed, 20 Jun 2018 10:03:55 -0400 From: Tom Lane To: Thomas Kellerer cc: pgsql-general@lists.postgresql.org Subject: Re: Plan output: actual execution time not considering loops? In-reply-to: References: Comments: In-reply-to Thomas Kellerer message dated "Wed, 20 Jun 2018 12:51:26 +0200" MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-ID: <7415.1529503434.1@sss.pgh.pa.us> Content-Transfer-Encoding: quoted-printable Date: Wed, 20 Jun 2018 10:03:54 -0400 Message-ID: <7416.1529503434@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk Thomas Kellerer writes: > Consider the following execution plan: > ... > =C2=A0=C2=A0=C2=A0 ->=C2=A0 Aggregate=C2=A0 (cost=3D26.87..26.87 rows=3D= 1 width=3D32) (actual time=3D0.012..0.012 rows=3D1 loops=3D700000) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 ->=C2=A0 Bitmap H= eap Scan on orders o2=C2=A0 (cost=3D3.45..26.85 rows=3D8 width=3D8) (actua= l time=3D0.004..0.008 rows=3D8 loops=3D700000) > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0= =C2=A0=C2=A0=C2=A0 ->=C2=A0 Bitmap Index Scan on orders_customer_id_order_= date_idx=C2=A0 (cost=3D0.00..3.45 rows=3D8 width=3D0) (actual time=3D0.003= ..0.003 rows=3D8 loops=3D700000) > My expectation would have been that the "Aggregate" step shows the actua= l time as a product of the number of loops. No, that looks fine to me. The rule of thumb for reading this is total time spent in/below this node is "actual time" times "number of loops". It seems a bit odd that the Agg node would account for a third of the total execution time when it's only processing 8 rows on average ... but maybe it's a really expensive aggregate. Another thought is that the EXPLAIN ANALYZE instrumentation itself can account for significant per-node-invocation overhead. If the total execution time drops significantly when you add "timing off" to the EXPLAIN options, then that's probably a factor in making the Agg node look relatively expensive. regards, tom lane