Re: [v9.5] Custom Plan API

From: Robert Haas <robertmhaas(at)gmail(dot)com>
To: Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com>
Cc: Kohei KaiGai <kaigai(at)kaigai(dot)gr(dot)jp>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Alvaro Herrera <alvherre(at)2ndquadrant(dot)com>, Shigeru Hanada <shigeru(dot)hanada(at)gmail(dot)com>, Simon Riggs <simon(at)2ndquadrant(dot)com>, Stephen Frost <sfrost(at)snowman(dot)net>, Andres Freund <andres(at)2ndquadrant(dot)com>, PgHacker <pgsql-hackers(at)postgresql(dot)org>, Jim Mlodgenski <jimmy76(at)gmail(dot)com>, Peter Eisentraut <peter_e(at)gmx(dot)net>
Subject: Re: [v9.5] Custom Plan API
Date: 2014-09-15 17:30:46
Message-ID: CA+TgmobihAjM1AFiFyp+QEJRfGuDotiA-bTKk=Xni4hYy5o8YQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On Mon, Sep 15, 2014 at 8:38 AM, Kouhei Kaigai <kaigai(at)ak(dot)jp(dot)nec(dot)com> wrote:
>> > The only reason why I put separate hooks here is, create_custom_scan()
>> > needs to know exact size of the CustomScan node (including private
>> > fields), however, it is helpful for extensions to kick its callback to
>> > initialize the node next to the common initialization stuff.
>>
>> Why does it need to know that? I don't see that it's doing anything that
>> requires knowing the size of that node, and if it is, I think it shouldn't
>> be. That should get delegated to the callback provided by the custom plan
>> provider.
>>
> Sorry, my explanation might be confusable. The create_custom_scan() does not
> need to know the exact size of the CustomScan (or its inheritance) because of
> the two separated hooks; one is node allocation time, the other is the tail
> of the series of initialization.
> If we have only one hook here, we need to have a mechanism to informs
> create_custom_scan() an exact size of the CustomScan node; including private
> fields managed by the provider, instead of the first hook on node allocation
> time. In this case, node allocation shall be processed by create_custom_scan()
> and it has to know exact size of the node to be allocated.
>
> How do I implement the feature here? Is the combination of static node size
> and callback on the tail more simple than the existing design that takes two
> individual hooks on create_custom_scan()?

I still don't get it. Right now, the logic in create_custom_scan(),
which I think should really be create_custom_plan() or
create_plan_from_custom_path(), basically looks like this:

1. call hook function CreateCustomPlan
2. compute values for tlist and clauses
3. pass those values to hook function InitCustomScan()
4. call copy_path_costsize

What I think we should do is:

1. compute values for tlist and clauses
2. pass those values to hook function PlanCustomPath(), which will return a Plan
3. call copy_path_costsize

create_custom_scan() does not need to allocate the node. You don't
need the node to be allocated before computing tlist and clauses.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Geoghegan 2014-09-15 17:34:39 Re: B-Tree support function number 3 (strxfrm() optimization)
Previous Message Claudio Freire 2014-09-15 17:23:54 Re: jsonb format is pessimal for toast compression