Re: [HACKERS] Relids in upper relations

2016-10-09 Thread Robert Haas
On Sun, Oct 9, 2016 at 6:33 PM, Tom Lane wrote: > Robert Haas writes: >> On Wed, Oct 5, 2016 at 9:42 AM, Tom Lane wrote: >>> I think this is fundamentally wrongheaded. If we go that route, >>> the only valid relids for any upper path would be the union of all >>> baserel RTIs, ... > >> Hmm, but

Re: [HACKERS] Relids in upper relations

2016-10-09 Thread David Rowley
On 10 October 2016 at 11:33, Tom Lane wrote: > Robert Haas writes: >> SELECT order_line.order_id, order.customer_id, SUM(order_line.amount) >> FROM order_line, order WHERE order_line.order_id = order.order_id >> GROUP BY 1,2; > >> Doing the aggregation step first is likely to be much faster than

Re: [HACKERS] Relids in upper relations

2016-10-09 Thread Tom Lane
Robert Haas writes: > On Wed, Oct 5, 2016 at 9:42 AM, Tom Lane wrote: >> I think this is fundamentally wrongheaded. If we go that route, >> the only valid relids for any upper path would be the union of all >> baserel RTIs, ... > Hmm, but this is only true if the upper steps are always done las

Re: [HACKERS] Relids in upper relations

2016-10-09 Thread Robert Haas
On Wed, Oct 5, 2016 at 9:42 AM, Tom Lane wrote: >> We could prevent the crash by passing input_rel->relids to >> fetch_upper_rel() in create_grouping_path() as seen in the attached >> patch. > > I think this is fundamentally wrongheaded. If we go that route, > the only valid relids for any upper

Re: [HACKERS] Relids in upper relations

2016-10-05 Thread Ashutosh Bapat
On Wed, Oct 5, 2016 at 7:12 PM, Tom Lane wrote: > Ashutosh Bapat writes: >> While reviewing aggregate pushdown patch [1] we noticed that >> RelOptInfos for upper relations do not have relids set. > > Indeed, because they don't correspond to any particular scan relation or > set of scan relations.

Re: [HACKERS] Relids in upper relations

2016-10-05 Thread Tom Lane
Ashutosh Bapat writes: > While reviewing aggregate pushdown patch [1] we noticed that > RelOptInfos for upper relations do not have relids set. Indeed, because they don't correspond to any particular scan relation or set of scan relations. I have in mind that in future releases, any particular u

[HACKERS] Relids in upper relations

2016-10-05 Thread Ashutosh Bapat
Hi, While reviewing aggregate pushdown patch [1] we noticed that RelOptInfos for upper relations do not have relids set. create_foreignscan_plan() copies the relids from RelOptInfo into ForeignScan::fs_relids. That field is used to identify the RTIs covered by the ForeignScan. For example, postgres