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