View containing a recursive function

Поиск
Список
Период
Сортировка
От Mathieu De Zutter
Тема View containing a recursive function
Дата
Msg-id CAH7GKCw50gRf75vWR75eB80kkJpO4t+o65xJ7LFgH2Fbu-Vztg@mail.gmail.com
обсуждение исходный текст
Ответы Re: View containing a recursive function
Список pgsql-performance
Hi all,

I have a recursive part in my database logic that I want to isolate and reuse as a view. I had found a blog that explained how move a function parameter into a view. The SQL is in attachment.
When I write a query based on that view with a fixed value (or values) for the (input) parameter, the planner does fine and only evaluates the function once.
However, when the value of the parameter should be deduced from something else, the planner doesn't understand that and will evaluate the function for each possible value.

Any pointers to what I'm doing wrong or on how to optimize it?

Attachment contains the queries and explain plans.

Thanks!

Kind regards,
Mathieu
Вложения

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

Предыдущее
От: Hedayat Vatankhah
Дата:
Сообщение: Re: PostgreSQL seems to create inefficient plans in simple conditional joins
Следующее
От: Albe Laurenz
Дата:
Сообщение: Re: Hash join gets slower as work_mem increases?