Re: Parallel query only when EXPLAIN ANALYZEd

From: David Rowley <david(dot)rowley(at)2ndquadrant(dot)com>
To: Jay Knight <jay(at)jayknight(dot)com>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: Parallel query only when EXPLAIN ANALYZEd
Date: 2016-09-29 21:29:01
Message-ID: CAKJS1f9GzQ1QJj7kyQq8N7W39aV7fjySsKEn0FBJzHtMDZLqeQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 30 September 2016 at 08:52, Jay Knight <jay(at)jayknight(dot)com> wrote:
> So, why might postgres parallelize the query when I explain analyze it, but
> not when I just run it by itself?

One theory would be that, the worker might not have been available
when you performed the query execution, but it just happened to be
when you did the EXPLAIN ANALYZE. If the executor can't get a free
worker process, then it'll just do all the work in the main process.
The plan parallel plan that you've shown, given no extra worker
processes, would most likely perform the same as the serial plan you
showed, since the extra Finalize Aggregate node is only handling 1 row
anyway.

What's max_worker_processes set to?

If this is just a test machine, you should be able to see what's going
on if you install auto_explain, and enable auto_explain.log_analyze
(https://www.postgresql.org/docs/current/static/auto-explain.html)
Setting this up will log the EXPLAIN ANALYZE to the PostgreSQL logs
when you execute the query as normal.

--
David Rowley http://www.2ndQuadrant.com/
PostgreSQL Development, 24x7 Support, Training & Services

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Alvaro Herrera 2016-09-29 21:40:15 Re: [HACKERS] pg_upgrade from 9.5 to 9.6 fails with "invalid argument"
Previous Message Venkata B Nagothi 2016-09-29 21:25:30 Re: Multi tenancy : schema vs databases