Re: FETCH FIRST clause WITH TIES option

From: Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com>
To: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
Cc: Surafel Temesgen <surafel3000(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: FETCH FIRST clause WITH TIES option
Date: 2018-10-29 16:08:38
Message-ID: 942526de-1854-2bdc-ad17-e276c1efeb1d@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

On 10/29/2018 04:17 PM, Andrew Gierth wrote:
>>>>>> "Tomas" == Tomas Vondra <tomas(dot)vondra(at)2ndquadrant(dot)com> writes:
>
> > On 10/26/2018 12:28 PM, Surafel Temesgen wrote:
> >> hello ,
> >>
> >> The WITH TIES keyword is sql standard that specifies any peers of
> >> retained rows to retained in the result set too .which means
> >> according to ordering key the result set can includes additional rows
> >> which have ties on the last position, if there are any and It work
> >> with ORDER BY query.
>
> Tomas> Thanks for the patch. I've looked at it today, and it seems
> Tomas> mostly OK, with a couple of minor issues. Most of it is code
> Tomas> formatting and comment wording issues, so I'm not going to go
> Tomas> through them here - see the attached 0002 patch (0001 is your
> Tomas> patch, rebased to current master).
>
> I still think that this is the wrong approach. Implementing WITH TIES
> and PERCENT together using an implicit window function call kills two
> birds with one very small stone (the only executor change needed would
> be teaching LIMIT to be able to stop on a boolean condition), with
> maximum reuse of existing facilities.
>

Hmmm, maybe. How would that work, exactly? Wouldn't that mean extra
overhead (the window functions are hardly free) and limitations? Perhaps
that was discussed in some other thread in the past?

FWIW, I doubt the patch can be much smaller/simpler - a significant part
of the new stuff is in gram.y and node read/out infrastructure, the
changes to LIMIT node are fairly minimal.

regards

--
Tomas Vondra http://www.2ndQuadrant.com
PostgreSQL Development, 24x7 Support, Remote DBA, Training & Services

In response to

Responses

Browse pgsql-hackers by date

  From Date Subject
Next Message Steve Crawford 2018-10-29 16:12:49 Re: date_trunc() in a specific time zone
Previous Message Vik Fearing 2018-10-29 15:43:40 Re: date_trunc() in a specific time zone