View containing a recursive function - Mailing list pgsql-performance

From Mathieu De Zutter
Subject View containing a recursive function
Date
Msg-id CAH7GKCw50gRf75vWR75eB80kkJpO4t+o65xJ7LFgH2Fbu-Vztg@mail.gmail.com
Whole thread Raw
Responses Re: View containing a recursive function
List 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
Attachment

pgsql-performance by date:

Previous
From: Hedayat Vatankhah
Date:
Subject: Re: PostgreSQL seems to create inefficient plans in simple conditional joins
Next
From: Albe Laurenz
Date:
Subject: Re: Hash join gets slower as work_mem increases?