Question: I am using Postgres. I am trying to execute two functions in PARALLEL, and then union their results - here is my code so far

I am using Postgres. I am trying to execute two functions in PARALLEL, and then union their results- here is my code so far (which throws the following error - SQL Error [25P02]: ERROR: current transaction is aborted, commands ignored until end of transaction block)- begin;
--------
WITH area_ids AS (
SELECT DISTINCT "areaID"::character varying
FROM campaign_scope cs
WHERE '2024-03-02' BETWEEN cs."campaignStartDate" AND cs."catchupEndDate"
),
area_id_counts AS (
SELECT COUNT(*) AS total_count
FROM area_ids
),
selected_area_ids AS (
SELECT "areaID"::character varying,
ROW_NUMBER() OVER (ORDER BY "areaID"::character varying) AS row_num
FROM area_ids
)
----------
,
results_1 as
(
SELECT inter.* FROM
(select * from public.interactions_looped_ucmo_aic(array(SELECT selected_area_ids."areaID"::character varying
FROM selected_area_ids
JOIN area_id_counts ON true
WHERE selected_area_ids.row_num <= area_id_counts.total_count /2
),'2024-03-02','2024-03-0206:00:00','2024-03-0218:00:00')
order by area_id,parent_imei,child_imei,parent_ping_time) as inter)
,
results_2 as
(
SELECT inter.* FROM
(select * from public.interactions_looped_ucmo_aic(array(SELECT selected_area_ids."areaID"::character varying
FROM selected_area_ids
JOIN area_id_counts ON true
WHERE selected_area_ids.row_num > area_id_counts.total_count /2
),'2024-03-02','2024-03-0206:00:00','2024-03-0218:00:00')
order by area_id,parent_imei,child_imei,parent_ping_time) as inter
)
SELECT * FROM result_1
UNION ALL
SELECT * FROM result_2;
commit;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!