As demonstrated in this recipe, parallelizing queries in PostgreSQL allows the optimization of operations that involve a large dataset. The database engine is already capable of implementing parallelism, but defining the proper configuration is crucial in order to take advantage of the functionality.
In this recipe, we used the max_parallel_workers and the parallel_tuple_cost to configure the desired amount a parallelism. We could evaluate the performance with the ANALYZE function.