From: | "Florian G(dot) Pflug" <fgp(at)phlo(dot)org> |
---|---|
To: | Cristiano Duarte <cunha17(at)gmail(dot)com> |
Cc: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-hackers(at)postgresql(dot)org |
Subject: | Re: SPI access to PostgreSQL query plan |
Date: | 2007-09-18 00:46:14 |
Message-ID: | 46EF1FD6.8010305@phlo.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-hackers |
Cristiano Duarte wrote:
> 2007/9/17, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> "Cristiano Duarte" <cunha17(at)gmail(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Sibte Abbas | 2007-09-18 02:45:23 | Re: Raw device I/O for large objects |
Previous Message | Georgi Chulkov | 2007-09-18 00:17:04 | Raw device I/O for large objects |