Hello,
I'm having a problem with the following:
CREATE TYPE Sums AS (sum_m1 double precision, sum_m2 double precision);
CREATE TYPE date_m1_m2 AS (cur_date date, sum_m1 double precision, sum_m2 double precision);
CREATE OR REPLACE FUNCTION getSums(IN start_ts timestamp with time
zone, IN stop_ts timestamp with time zone) RETURNS Sums AS $$
...
CREATE OR REPLACE FUNCTION getsumInterval(date, date) RETURNS SETOF date_m1_m2 AS $$
SELECT
cur_date,
(getSums(start_ts, stop_ts)).* -- No optimal since function is evaluated 2 times => 24s
-- getSums(start_ts, stop_ts) -- in one column and not usable as I need 2 columns, but takes only 12s
FROM
getDatesTimestamps($1, $2)
;
$$ LANGUAGE SQL;
Since getSums() is a cursor and is complex and takes long time getSums
should only be evaluated once. Is there a better solution available to
get both columns from the function in the select?
Thnx.
Ciao,
Gerhard
--
http://www.wiesinger.com/
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general