Re: Range types

From: Andrew Gierth <andrew(at)tao11(dot)riddles(dot)org(dot)uk>
To: tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane), Dimitri Fontaine <dfontaine(at)hi-media(dot)com>, hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: Range types
Date: 2009-12-17 15:55:27
Message-ID: 87my1hlizp.fsf@news-spur.riddles.org.uk
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

>>>>> "Tom" == Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:

Someone mentioned LATERAL?

>> Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> writes:
>>> Hm, how would you do it with LATERAL? The problem is not so much
>>> composition as the need for a variable number of rounds of
>>> composition.

>> Let's have a try at it:

>> select p2_member, array_accum(p1)
>> from unnest(p2) as p2_member
>> lateral (select period_except(p1_member, p2_member)
>> from unnest(p1) p1_member) as x(p1);

Tom> I don't think that does it. Maybe I misunderstand LATERAL, but
Tom> what that looks like to me is that each p1 will be separately
Tom> filtered by each p2, giving rise to a distinct element in the
Tom> output. What we need is for each p1 to be filtered by *all*
Tom> p2's, successively (though in any order).

Right, that's not a job for LATERAL, though it could be done easily
enough in one statement with a recursive CTE, I think.

--
Andrew (irc:RhodiumToad)

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Tom Lane 2009-12-17 15:55:28 Re: determine snapshot after obtaining locks for first statement
Previous Message Kevin Grittner 2009-12-17 15:39:46 Re: determine snapshot after obtaining locks for first statement