0

I am using PostgreSQL's Server Programming Interface (SPI) to build my postgres extension and execute my query. Please see this detailed example, or the following simple code sample:

int ret = SPI_exec("SELECT * FROM ....", 0);

We know that PostgreSQL has parallel query support feature, where a query is executed in parallel using multiple processors. Since the SPI interface hides quite some complexity (communication/locks/cursors/etc), I was wondering whether executing a query in this way limits this parallel query feature in some way or not? Obviously, if it does indeed pose a limit, then maybe it is not worth making use of.

Zeruno
  • 1,391
  • 2
  • 20
  • 39

1 Answers1

3

The specific usage in your example does not inhibit parallelism, as can be seen by running SELECT execq('select count(*) from pgbench_accounts', 0); and observing the plan via auto_explain. (I had run pgbench -i -s20, so there 2e6 rows).

Other SPI method, like those involving cursors, will inhibit parallelization.

jjanes
  • 37,812
  • 5
  • 27
  • 34