Hi, Is there a way to have access to PostgreSQL query plan and/or predicates inside a function using spi (or any other way)? For example:
explain select * from my_func() as (code int, name varchar) where name like 'a%'; QUERY PLAN -------------------------------------------------------------- Function Scan on my_func (cost=0.00..15.00 rows=5 width=36) Filter: ((name)::text ~~ 'a%'::text) I would like to know, inside the my_func function that PostgreSQL will filter the function's returned result on the name column with a like operator matching 'a%'. Since inside the my_func function I do another database query, I could "pre-filter" this query and reduce the amount of records returned. If the whole plan cannot be exposed to spi, can only the part involved on filtering/manipulating the records returned from the function call? Is the query plan saved in memory at a place where a spi function can have access? Regards, Cristiano Duarte.