Question: I am using PostGIS to calculate length of interactions between two types of employees. I am performing the same set of operations for each area
I am using PostGIS to calculate length of interactions between two types of employees. I am performing the same set of operations for each area id Here is my code:
CREATE OR REPLACE FUNCTION public.interactionsloopeducmoaicareaidarray character varying ddate date, starttime timestamp without time zone, endtime timestamp without time zone
RETURNS TABLEareaid uuid, "createdAt timestamp without time zone, "updatedAt timestamp without time zone, ID character varying, parentimei character varying, childimei character varying, parentpingtime timestamp without time zone, childpingtime timestamp without time zone, maxima timestamp without time zone, minima timestamp without time zone, "interactionID" character varying, interactiontype character varying
LANGUAGE plpgsql
AS $function$
DECLARE
i integer :;
BEGIN
FOR i IN arraylengthareaidarray, LOOP
RETURN QUERY
with pings as
select
from
SELECTING Parent INFO
select
pimei,
sttransformp"geoJson", as geom,
"generatedAt" as t
pID as upingid
from
campaignpings p
where
"generatedAt" interval hours' between starttime and endtime
and
pimei in
multiple left joins
u
left join SELECTING child INFO
SELECT
pimei,
pID as apingid
sttransformp"geoJson", as geom,
"generatedAt" as t
FROM
campaignpings p
where
"generatedAt" interval hours' between starttime and endtime
and
pimei in
multiple left joins
a on STDWithinu"geom", a"geom",
and at BETWEEN ut INTERVAL seconds'
and ut INTERVAL seconds'
where
aimei is not null
more code to calculate length of continuous interactions in minutes
;
END LOOP;
END
$function$
;
So essentially, I am performing the same set of operations for each area id Is there a way to make use of caching here to reduce execution time? I mean to enforce the use of cache.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
