5

Postgres now has parallel queries. Are parallel queries used when the table is partitioned, the query is on the master table, and more than one partitions (child tables) are involved.

For example, I partition by the hour of the day. Then I want to count a type of event over more than one hour. The aggregation can be done on each partition, with the results added up at the end.

The alternative is to use a union between the partitions (child tables). In this case Postgres does parallel execution.

1
  • PostgreSQL 9.5 and older: no. PostgreSQL 9.6 and newer: check the query plan. Where's the explain analyze? Edit your post to add it please. Commented Nov 25, 2016 at 4:20

1 Answer 1

0

No, partitions are not queried in parallel. At this time (9.6) only table scans use parallel execution. The table is divided among the available workers, and each worker scans part of the table. At the end the primary worker combines the partial results.

A side effect of this is that the optimizer is more likely to chose a full table scan when parallel query execution is enabled.

As far as I can tell, there is no plan to parallelize execution based on partitions (or union all). A suggestion to add this has been added here.

Edit: My original answer was wrong. This answer has been completely revised.

Sign up to request clarification or add additional context in comments.

1 Comment

Hello there, I have and issue and presented here I wonder if this paralelism can help me in a table scan when a field is a function (also table scan) is included. Currently Im using 9.5 so Im considering migrating to 9.6 just for this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.