A rather hackish POC for alternative implementation of WITH TIES - Mailing list pgsql-hackers

From Andrew Gierth
Subject A rather hackish POC for alternative implementation of WITH TIES
Date
Msg-id 87o8wvz253.fsf@news-spur.riddles.org.uk
Whole thread Raw
Responses Re: A rather hackish POC for alternative implementation of WITH TIES  (Surafel Temesgen <surafel3000@gmail.com>)
List pgsql-hackers
This patch is a rather hacky implementation of the basic idea for
implementing FETCH ... WITH TIES, and potentially also PERCENT, by using
a window function expression to compute a stopping point.

Large chunks of this (the parser/ruleutils changes, docs, tests) are
taken from Surafel Temesgen's patch. The difference is that the executor
change in my version is minimal: Limit allows a boolean column in the
input to signal the point at which to stop. The planner inserts a
WindowAgg node to compute the necessary condition using the rank()
function.

The way this is done in the planner isn't (IMO) the best and should
probably be improved; in particular it currently misses some possible
optimizations (most notably constant-folding of the offset+limit
subexpression). I also haven't tested it properly to see whether I broke
anything, though it does pass regression.

-- 
Andrew (irc:RhodiumToad)


Attachment

pgsql-hackers by date:

Previous
From: "nagaura.ryohei@fujitsu.com"
Date:
Subject: RE: [patch]socket_timeout in interfaces/libpq
Next
From: Michael Paquier
Date:
Subject: Re: pgbench - add \aset to store results of a combined query