Allow parallel plan for referential integrity checks?

Поиск
Список
Период
Сортировка
От Frédéric Yhuel
Тема Allow parallel plan for referential integrity checks?
Дата
Msg-id 0d21e3b4-dcde-290c-875e-6ed5013e8e52@dalibo.com
обсуждение исходный текст
Ответы Re: Allow parallel plan for referential integrity checks?  (Andreas Karlsson <andreas@proxel.se>)
Re: Allow parallel plan for referential integrity checks?  (Robert Haas <robertmhaas@gmail.com>)
Список pgsql-hackers
Hello,

I noticed that referential integrity checks aren't currently 
parallelized. Is it on purpose?

 From the documentation [1], the planner will not generate a parallel 
plan for a given query if any of the following are true:

1) The system is running in single-user mode.
2) max_parallel_workers_per_gather = 0.
3) The query writes any data or locks any database rows.
4) The query might be suspended during execution (cursor or  PL/pgSQL loop).
5) The query uses any function marked PARALLEL UNSAFE.
6) The query is running inside of another query that is already parallel.

 From my understanding of the code, it seems to me that the fourth 
condition is not always accurately detected. In particular, the query 
triggered by a foreign key addition (a Left Excluding JOIN between the 
two tables) isn't parallelized, because the flag CURSOR_OPT_PARALLEL_OK 
hasn't been set at some point. I couldn't find any reason why not, but 
maybe I missed something.

Attached is a (naive) patch that aims to fix the case of a FK addition, 
but the handling of the flag CURSOR_OPT_PARALLEL_OK, generally speaking, 
looks rather hackish.

Best regards,
Frédéric

[1] 
https://www.postgresql.org/docs/current/when-can-parallel-query-be-used.html
Вложения

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

Предыдущее
От: Yugo NAGATA
Дата:
Сообщение: Re: Fix CheckIndexCompatible comment
Следующее
От: Julien Rouhaud
Дата:
Сообщение: Re: Database-level collation version tracking