Skip site navigation (1) Skip section navigation (2)

Re: review: More frame options in window functions

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
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-18 19:32:20
Message-ID: 12108.1263843140@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-hackers
Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com> writes:
> 2010/1/17 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
>> 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.

No, it has to be false in calls made before query_planner runs and true
afterwards.  There's no flexibility there.

> 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.

Maybe we're just talking past each other.  My point is that the planner
should record the fact that four is the sort column someplace where the
executor can find it easily.  AFAICS that doesn't mean it can't be the
canonicalized form of the sort key.  If a column is dropped out of the
canonical sort key then it's simply redundant, and hence not relevant to
determining the range.

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Robert HaasDate: 2010-01-18 20:19:06
Subject: Re: quoting psql varible as identifier
Previous:From: Brad T. SligerDate: 2010-01-18 19:29:48
Subject: Re: Pretty printed trigger in psql

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group