The following query
EXPLAIN
SELECT c.global_id
FROM centers_res17 AS c
LEFT JOIN regions_res17 AS r ON ST_Contains(r.wkb_geometry, c.wkb_geometry)
WHERE r.global_id IS NULL;
says that a Parallel Sequential Scan on centers_res17
will be used. This is good and the query is fast (8 workers are used, and the CPU is busy)
Now, if I do a SELECT c.global_id INTO foo
the query plan indicates a Sequential Scan, which is much slower.
I tried to:
CREATE
the foo table before (also as aTEMP
)- Wrap the above statement in a
WITH
clause and then select its results into foo. CREATE foo AS (^^Above statement^^)
None of the above uses multiple workers to do a Parallel Sequential Scan (according to the query plan and actually running the query). I could just make the select statement 'as is' and then copy-paste the values from my results window ... not optimal.
Please explain to me, why the Parallel Sequential Scan is not used, or how to modify my query to have the results selected into foo
.
I am using PostgreSQl 9.6 on Win10.
-
To run my query with multiple workers, I copy the results to a file as discussed here stackoverflow.com/questions/1517635/…Michael– Michael2018年02月20日 08:41:55 +00:00Commented Feb 20, 2018 at 8:41
1 Answer 1
The planner will not generate them for a given query if any of the following are true
- The query writes any data or locks any database rows. If a query contains a data-modifying operation either at the top level or within a CTE, no parallel plans for that query will be generated. This is a limitation of the current implementation which could be lifted in a future release.
As you are inserting rows into a table, the underlying query will never use parallelism, at least not in current version (10) and earlier.
-
understood. only read operations are parallel.Michael– Michael2018年02月20日 08:42:33 +00:00Commented Feb 20, 2018 at 8:42
Explore related questions
See similar questions with these tags.