Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK

Поиск
Список
Период
Сортировка
От mobigroup
Тема Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK
Дата
Msg-id 3879EBE6-399D-4CAF-9C37-D5CA656DB77C@mobigroup.ru
обсуждение исходный текст
Ответ на Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK  (Laurenz Albe <laurenz.albe@cybertec.at>)
Ответы Re: PostgreSQL 12.4 Parallel Query doesn't work while EXPLAIN is OK
Список pgsql-general
Thanks for the ideas, I tested them:

The essential question here is when the function is executed, so you should use
EXPLAIN (VERBOSE) to see that.

Append  (cost=0.00..5.12 rows=4 width=32)
  ->  Gather  (cost=0.00..1.26 rows=1 width=32)
        Output: plpgsql_function(...)
        Workers Planned: 8
        ->  Parallel Seq Scan on public.table t  (cost=0.00..1.01 rows=1 width=174)
              Output: ...
              Filter: (t.id = 1)
  ->  Gather  (cost=0.00..1.26 rows=1 width=32)
        Output: plpgsql_function(...)
        Workers Planned: 8
        ->  Parallel Seq Scan on public.table t_1  (cost=0.00..1.01 rows=1 width=174)
              Output: ...
              Filter: (t_1.id = 2)

Possible explanations:

- The function is executed after the "Gather" node.

The question is - could we do something to fix it?

 Perhaps you didn't define it as PARALLEL SAFE.

The function is marked as "PARALLEL RESTRICTED” because it’s uses temp tables (and I tested it as PARALLEL SAFE with the same result… parallelisation doesn’t work anyway).


- Perhaps the tables are small.

Yes, but these settings applied when the table is created:

analyze table;
set parallel_setup_cost = 0;
set parallel_tuple_cost = 0;
set force_parallel_mode = on;
alter table table set (parallel_workers = 8);

P.S. Actually, I just need to run in parallel mode one function with a set of different arguments to utilise all available CPUs. That’s strange but I couldn’t google a way to do it.

В списке pgsql-general по дате отправления:

Предыдущее
От: Atul Kumar
Дата:
Сообщение: error on connecting port 5432
Следующее
От: Adrian Klaver
Дата:
Сообщение: Re: error on connecting port 5432