Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs

Поиск
Список
Период
Сортировка
От David Rowley
Тема Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs
Дата
Msg-id CAApHDvpVYC43mi8atZ2Q39emK45xh7AaXetMJE9gJyV6sge_mg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: Teaching planner to short-circuit empty UNION/EXCEPT/INTERSECT inputs
Список pgsql-hackers
On Fri, 3 Oct 2025 at 04:18, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> 0001's change in is_dummy_rel() seems like a complete hack, especially
> since you didn't bother to change the adjacent comment.  Why is that
> necessary?

build_setop_child_paths() wraps the child inputs in SubqueryScanPaths,
so we need to see through those.

An alternative way would be to propagate those during build_setop_child_paths()

--- a/src/backend/optimizer/prep/prepunion.c
+++ b/src/backend/optimizer/prep/prepunion.c
@@ -523,6 +523,13 @@ build_setop_child_paths(PlannerInfo *root, RelOptInfo *rel,
  bool is_sorted;
  int presorted_keys;

+     /* If the input rel is dummy, propagate that to this query level */
+     if (is_dummy_rel(final_rel))
+     {
+         mark_dummy_rel(rel);
+         continue;
+     }
+

As attached.

> v2 LGTM otherwise.

Thanks

David

Вложения

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