Concatenate result from several queries - parallelization

19 Views Asked by At

I have a couple of queries (2-4) which are independent and results of which I need to concatenate once all are finished.

Since I don't know about how postgresql works under the hood, I am wondering:

  1. Do queries run in parallel automatically?
  2. Can I force them to run in parallel if they dont do it automatically?
  3. Should I do it?

I would like to avoid running them in serial fashion if parallelization is possible.

Pseudo code of my scenario:

(
  SELECT func(col1, col2, col3)
  FROM table1
  JOIN...
  WHERE...
)
||
(
  SELECT func(col1, col2, col3)
  FROM table2
  JOIN...
  WHERE...
)
||
(
  SELECT func(col1, col2, col3)
  FROM table3
  JOIN...
  WHERE...
)
0

There are 0 best solutions below