pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Thomas Kellerer <spam_eater@gmx.net>
To: pgsql-general@lists.postgresql.org
Subject: Plan output: actual execution time not considering loops?
Date: Wed, 20 Jun 2018 12:51:26 +0200
Message-ID: <c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net> (raw)

Consider the following execution plan:

Seq Scan on orders o1  (cost=0.00..18818840.86 rows=3500 width=16) (actual time=0.033..8625.104 rows=99906 loops=1)
  Filter: (amount = (SubPlan 1))
  Rows Removed by Filter: 600094
  Buffers: shared hit=7719778
  SubPlan 1
    ->  Aggregate  (cost=26.87..26.87 rows=1 width=32) (actual time=0.012..0.012 rows=1 loops=700000)
          Buffers: shared hit=7714631
          ->  Bitmap Heap Scan on orders o2  (cost=3.45..26.85 rows=8 width=8) (actual time=0.004..0.008 rows=8 loops=700000)
                Recheck Cond: (customer_id = o1.customer_id)
                Heap Blocks: exact=5597311
                Buffers: shared hit=7714631
                ->  Bitmap Index Scan on orders_customer_id_order_date_idx  (cost=0.00..3.45 rows=8 width=0) (actual time=0.003..0.003 rows=8 loops=700000)
                      Index Cond: (customer_id = o1.customer_id)
                      Buffers: shared hit=2117320
Planning time: 0.136 ms
Execution time: 8628.724 ms

My expectation would have been that the "Aggregate" step shows the actual time as a product of the number of loops.

The Bitmap Heap Scan takes 0.008ms for each execution, so shouldn't the "actual time" for the "Aggregate" step be 0.008ms * 700000 (= 5600ms)?

The plan was generated using Postgres 10.4 (on Windows 10, but I think that is irrelevant)

Thomas

view thread (3+ messages)  latest in thread

Message-ID: <c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net>
Permalink:  ../c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net/
Also on:    postgresql.org/message-id/c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: spam_eater@gmx.net
  Subject: Re: Plan output: actual execution time not considering loops?
  In-Reply-To: <c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net>
  References: <c920e568-5b6a-7014-b2a4-6a59c403a704@gmx.net>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox