BUG #15232: Query execution changes based on using 'explain analyze'or not - Mailing list pgsql-bugs

From PG Bug reporting form
Subject BUG #15232: Query execution changes based on using 'explain analyze'or not
Date
Msg-id 152838510590.26728.14913938912964455418@wrigleys.postgresql.org
Whole thread Raw
Responses Re: BUG #15232: Query execution changes based on using 'explain analyze' or not  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
The following bug has been logged on the website:

Bug reference:      15232
Logged by:          durandal mk2
Email address:      jgardner@comprehend.com
PostgreSQL version: 10.4
Operating system:   ubuntu 18.04
Description:

Testing behavior of parallel scans in 10.4 (looking to upgrade from 9.4) and
I'm only seeing parallel execution if I use "explain analyze".

Table setup is document_id int, version_id string 46million records

select
        document_id, 
        max(version_id) version_id 
from
        document_metadata
group by 1 

18 seconds, only a single process running

explain analyze
select
        document_id, 
        max(version_id) version_id 
from
        document_metadata
group by 1

same query but with explain analyze in front, I see multiple bgworker
processes spawn, 4 cores full loaded and query returns in 9 seconds

Finalize HashAggregate  (cost=927376.47..927830.76 rows=45429 width=38)
(actual time=8724.608..9001.714 rows=702294 loops=1)
  Group Key: document_id
  ->  Gather  (cost=907842.00..926467.89 rows=181716 width=38) (actual
time=7162.089..7962.289 rows=1460816 loops=1)
        Workers Planned: 4
        Workers Launched: 3
        ->  Partial HashAggregate  (cost=906842.00..907296.29 rows=45429
width=38) (actual time=7157.322..7303.906 rows=365204 loops=4)
              Group Key: document_id
              ->  Parallel Seq Scan on document_metadata
(cost=0.00..849274.00 rows=11513600 width=16) (actual time=0.043..3380.886
rows=11513600 loops=4)
Planning time: 0.122 ms
Execution time: 9032.855 ms

Scanning the lists and googling didn't really turn up anything, if this is
unexpected I'll try regressing this against 10.3.

No combination of the following parameters seems to impact the query planner
when not using explain analyze.  Thanks in advance.

set max_parallel_degree = 4;
set min_parallel_relation_size = 0;
set parallel_setup_cost to 0;
set parallel_tuple_cost to 0;
set force_parallel_mode to on;


pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: chkpass Major Issue - compares 'contains' and not 'equal'
Next
From: Tom Lane
Date:
Subject: Re: BUG #15232: Query execution changes based on using 'explain analyze' or not