From: | Rémi Cura <remi(dot)cura(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Computing (disjoint) union of range |
Date: | 2013-09-13 08:42:05 |
Message-ID: | CAJvUf_thbJjNSj9LUjgntzfCsToeSS5cxdV+bfxibN2pUh2M3Q@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hello Dear list,
this is more a plpgsql dev. issue.
I wrote a plpgsql function to compute union of time range taht works :
[1,4]U[3,8]U[12,14]U[16,18] ---> [1,8]U[12,14]U[16,18]
It works on multiple rows.
My issue is a design issue :
I want to work on set of row and return set of row.
I am aware I could take as input/output array of range but I don't want
(memory/casting cost).
Currently the function takes a cursor on a table and output a setof record.
I would like that the function can blend in multiple subqueries smoothly, as
WITH (
first query to get range),
(query computing union
),
(query using computed union
) etc.
Currently I have to execute 2 sql statment :
create cursor on ranges;
WITH (function to compute union)
,
(query...)
The only kind of function taking set of record as input I know of is
aggregate function, but it returns only one row and the output of union can
take multiple row.
Any insight would be greatly appreciated.
Cheers,
Rémi-C
From | Date | Subject | |
---|---|---|---|
Next Message | Andrew G. Saushkin | 2013-09-13 11:52:38 | Qury plan for sql function with security definer |
Previous Message | Tom Lane | 2013-09-13 06:53:57 | Re: Risk of set system wise statement_timeout |