SPI access to PostgreSQL query plan

From: "Cristiano Duarte" <cunha17(at)gmail(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: SPI access to PostgreSQL query plan
Date: 2007-09-17 13:54:09
Message-ID: 36bc054c0709170654g575d7fb9tbc2f53b1e4c2384@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

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.

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2007-09-17 14:19:49 Re: SPI access to PostgreSQL query plan
Previous Message Tom Lane 2007-09-17 13:44:21 Re: [COMMITTERS] pgsql: Fix up text concatenation so that it accepts all the reasonable