Re: [HACKERS] More on GROUP BY - Mailing list pgsql-hackers

From Bruce Momjian
Subject Re: [HACKERS] More on GROUP BY
Date
Msg-id 199905111901.PAA21290@candle.pha.pa.us
Whole thread Raw
In response to Re: [HACKERS] More on GROUP BY  (Tom Lane <tgl@sss.pgh.pa.us>)
Responses Re: [HACKERS] More on GROUP BY  (jwieck@debis.com (Jan Wieck))
List pgsql-hackers
> >     Wouldn't it be better to have another field (resgroupno e.g.)
> >     in the resdom  which  the  GroupClause  can  reference?  Then
> >     changing  the resno's or even replacing the entire expression
> >     wouldn't hurt because  make_subplanTargetList()  could  match
> >     them  this  way  and  the expressions for the subplans can be
> >     pulled out directly from the targetlist. And  it  would  save
> >     processing  the  group  clauses in the rewriting because they
> >     cannot contain Var nodes anymore and the entire list  can  be
> >     ignored.
> 
> I think I like better the idea of leaving the representation alone,
> but using equal() on the exprs to match groupclause items to targetlist
> entries.  That way, manipulation of the targetlist can't accidentally
> cause the grouplist to look like it contains something different than
> what it should have.  It doesn't bother me that the planner can fail
> if it is unable to match a group item to a targetlist item --- that's
> a good crosscheck that nothing's gone wrong.  (But matching on just
> the resno is unsafe, as you said before.)

The real problem is that it is hard to keep all these items synchronized
as they pass around through the stages.  I looked at the aggregates, and
it looks like that has a separate copy too, so it may not be that bad. 
We may just be missing a pass that makes appropriate changes in GROUP
clauses, but I am not sure.


> I think it's true that using a TLE for each grouplist item is a waste of
> space, and that representing the grouplist as simply a list of expr's
> would be good enough.  But pulling out the TLE decoration seems like
> it's not an appropriate use of time at this stage of the release cycle.
> I'd say hold off till after 6.5, then fold it in with the parsetree
> redesign that you keep muttering we need (I agree!).

Basically, it is my fault that I am bringing up the issue so late.  If I
had done the Open Items list earlier, we would not be so close to the
final.

Jan is currently researching it, and we have the regression tests and
three weeks.  He usually does a fine job of fixing things.  Jan, find
out what you think is required to get this working, and if it is not too
bad, maybe we should go ahead.

What does the Aggreg do?  Does it has similar duplication?

--  Bruce Momjian                        |  http://www.op.net/~candle maillist@candle.pha.pa.us            |  (610)
853-3000+  If your life is a hard drive,     |  830 Blythe Avenue +  Christ can be your backup.        |  Drexel Hill,
Pennsylvania19026
 


pgsql-hackers by date:

Previous
From: Christopher Masto
Date:
Subject: Re: [HACKERS] 6.5 TODO list
Next
From: Vince Vielhaber
Date:
Subject: RE: [HACKERS] web site addition