Re: Why the sql is not executed in parallel mode - Mailing list pgsql-general

From Thomas Munro
Subject Re: Why the sql is not executed in parallel mode
Date
Msg-id CAEepm=03s4Yih+c0pCTfKi0O8zgq-P4VfCVEk5VVXcR6aXHm4A@mail.gmail.com
Whole thread Raw
In response to Why the sql is not executed in parallel mode  (jimmy <mpokky@126.com>)
List pgsql-general
On Wed, Sep 19, 2018 at 1:53 PM jimmy <mpokky@126.com> wrote:
>
> Why the sql is not executed in parallel mode, does the sql has some problem?
> with sql1 as

Hello Jimmy,

WITH is the problem.  From the manual[1]:  "The following operations
are always parallel restricted.  Scans of common table expressions
(CTEs). ...".  That means that these CTEs can only be scanned in the
leader process.

If you rewrite the query using sub selects it might do better.  FWIW
there is a project to make WITH work like subselects automatically in
a future release of PostgreSQL:

https://www.postgresql.org/message-id/flat/87sh48ffhb.fsf@news-spur.riddles.org.uk

[1] https://www.postgresql.org/docs/10/static/parallel-safety.html

-- 
Thomas Munro
http://www.enterprisedb.com


pgsql-general by date:

Previous
From: jimmy
Date:
Subject: Why the sql is not executed in parallel mode
Next
From: Thomas Munro
Date:
Subject: Re: how to know whether query data from memory after pg_prewarm