Re: review: More frame options in window functions

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Erik Rijkers <er(at)xs4all(dot)nl>, PostgreSQL-development <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: review: More frame options in window functions
Date: 2010-01-17 06:28:45
Message-ID: e08cc0401001162228o59af246fs1ce10972c11da5cc@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

2010/1/17 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
>> ... I tried to change not to canonicalize the
>> pathkeys in make_pathkeys_window() in such cases and succeeded then
>> passed all regression tests.
>
> That's broken, whether it passes regression tests or not.  Not
> canonicalizing will mean that you fail to recognize equality to
> canonicalized pathkeys, and thus for example execute unnecessary
> sorts.

So why did you leave "canonicalize" argument in
make_pathkeys_for_window()? I thought you'd thought it would be needed
false in the future.

> I haven't looked at the patch, but it sounds a bit like you are trying
> to put logic into the executor that needs to be in the planner.  If the
> executor is guessing about what the planner did, that's a design
> failure.  The planner should figure out what needs to happen and tell
> the executor exactly what to do, eg, which columns need to be compared
> to determine partition membership.

I'd think I'm putting logic into the planner that needs to be in the
executor. Anyways, RANGE offset mode is quite different from existing
framework.

In a RANGE offset mode query, for example:

SELECT sum(ten) over (PARTITION BY four ORDER BY four RANGE BETWEEN 2
PRECEDING AND 1 PRECEDING) FROM tenk1

the frame is determined as "from the first row which has <four> value
- 2 to the last row which has <four> value - 1" and executor should
know <four> value *is* the sort column even if the column is not
actually significant. But the planner removes that information. It
seems to me that what you say above is to put logic into the planner
how to determine the frame, but I'd think the planner should leave
that information about sort column for the executor, of course in
another way than non-canonicalizing approach.

I'll try it that way. If I'm missing something still, please point it out.

Regards,

--
Hitoshi Harada

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Magnus Hagander 2010-01-17 12:56:25 Re: Archive recovery crashes on win32 in HEAD - hot standby related?
Previous Message Robert Haas 2010-01-17 00:33:13 Re: Clearing global statistics