Skip to main content

Parallel SQL Query Processing (PostgreSQL 10)

Is it possible to enable parallel SQL query processing in PostgreSQL 10?

Written by Petr Pech

Yes, PostgreSQL 10 supports parallel query processing.

👉 The database can split a single query into multiple parts and process them concurrently (e.g., when reading large volumes of data).


Limitations

Parallel processing will not be used if the query contains functions that are not marked as PARALLEL SAFE.

Typically:

  • the bigid function is not parallel-safe by default


Solution

Functions can be marked as parallel-safe:

ALTER FUNCTION public.bigid(bigint, bigint)
PARALLEL SAFE;
ALTER FUNCTION public.bigid(character varying, character varying, character varying, character varying, character varying)
PARALLEL SAFE;


Note

  • marking a function as PARALLEL SAFE means it has no side effects

  • only apply this change if you are certain the function is safe

Did this answer your question?