Re: SPI access to PostgreSQL query plan

Поиск
Список
Период
Сортировка
От Florian G. Pflug
Тема Re: SPI access to PostgreSQL query plan
Дата
Msg-id 46EF1FD6.8010305@phlo.org
обсуждение исходный текст
Ответ на Re: SPI access to PostgreSQL query plan  ("Cristiano Duarte" <cunha17@gmail.com>)
Ответы Re: SPI access to PostgreSQL query plan  (Michael Glaesemann <grzm@seespotcode.net>)
Список pgsql-hackers
Cristiano Duarte wrote:
> 2007/9/17, Tom Lane <tgl@sss.pgh.pa.us>:
>> "Cristiano Duarte" <cunha17@gmail.com> writes:
>>> Is there a way to have access to PostgreSQL query plan and/or predicates 
>>> inside a function using spi (or any other way)?
>> No.
>> 
>> Hi Tom,
> 
> "No" means: there is no way since the query plan is stored in a 
> secret/safe/protected/non-visible/fort-knox like place :) or it means, there
> is no friendly way to do it with spi or casual c language programming?

"No" as in: You function is not told by the executor which filters are applied
to it's results, and since it might be called multiple times within a query you
cannot figure that out yourself, even if you somehow got hold of the currently
executed plan.

So unless you start to hack the executor in serious ways, you'll either have to
pass the filter condition manually to your function, or live with it producing
unnecessary output rows.

Thats only holds true for functions in languages other than pl/sql (Which is
*not* the same as pl/pgsql) - SQL functions can be inlined by the executor, and
then are subject to the usual optimizations. (So they essentially behave like
views).

greetings, Florian Pflug



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

Предыдущее
От: Guillaume Lelarge
Дата:
Сообщение: Re: errcontext function
Следующее
От: Georgi Chulkov
Дата:
Сообщение: Raw device I/O for large objects