pg.ddx.io  pgsql-docs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: PG Doc comments form <noreply@postgresql.org>
To: pgsql-docs@lists.postgresql.org
Cc: tanghy.fnst@fujitsu.com
Subject: "actual time" in QUERY PLAN for parallel operation when loops is bigger than 1
Date: Tue, 16 Nov 2021 09:37:21 +0000
Message-ID: <163705544128.11069.9460699508957759732@wrigleys.postgresql.org> (raw)

The following documentation comment has been logged on the website:

Page: https://www.postgresql.org/docs/14/using-explain.html
Description:

https://www.postgresql.org/docs/14/using-explain.html
The doc says
"the loops value reports the total number of executions of the node, and the
actual time and rows values shown are averages per-execution. This is done
to make the numbers comparable with the way that the cost estimates are
shown."

But I found for parallel operation, the above description maybe not
correct.

For example 
postgres=# create table c(id int);
CREATE TABLE
postgres=# insert into c select generate_series(1,1000000);
INSERT 0 1000000
postgres=# explain analyze select count(*) from c;
                                                             QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------
 Finalize Aggregate  (cost=10633.55..10633.56 rows=1 width=8) (actual
time=290.460..290.508 rows=1 loops=1)
   ->  Gather  (cost=10633.33..10633.54 rows=2 width=8) (actual
time=289.605..290.484 rows=3 loops=1)
         Workers Planned: 2
         Workers Launched: 2
         ->  Partial Aggregate  (cost=9633.33..9633.34 rows=1 width=8)
(actual time=188.336..188.337 rows=1 loops=3)
               ->  Parallel Seq Scan on c  (cost=0.00..8591.67 rows=416667
width=0) (actual time=0.030..140.036 rows=333333 loops=3)
 Planning Time: 0.331 ms
 Execution Time: 290.607 ms
(8 rows)

postgres=# 

According to PG-doc, the "Parallel Seq Scan" node cost 140.036*3=420ms, but
the total cost for this SQL is only 290ms.
Is the output of this explain correct?


view thread (5+ messages)  latest in thread

Message-ID: <163705544128.11069.9460699508957759732@wrigleys.postgresql.org>
Permalink:  ../163705544128.11069.9460699508957759732@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/163705544128.11069.9460699508957759732@wrigleys.postgresql.org

 · 

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 using the --to and --cc options:
  reply via email

  To: pgsql-docs@postgresql.org
  Cc: noreply@postgresql.org, pgsql-docs@lists.postgresql.org, tanghy.fnst@fujitsu.com
  Subject: Re: "actual time" in QUERY PLAN for parallel operation when loops is bigger than 1
  In-Reply-To: <163705544128.11069.9460699508957759732@wrigleys.postgresql.org>

* 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