             AND d_part.campaign_id = d_whole.campaign_id
             AND d_part.region_id = d_whole.region_id;
 
-        CREATE INDEX ind_ix on datapoint_with_computed (indicator_id);
-        CLUSTER datapoint_with_computed using ind_ix;
-
         INSERT INTO datapoint_with_computed
         (indicator_id,region_id,campaign_id,value,is_calc)
 
-
         SELECT
-			denom.master_indicator_id
-          		,denom.region_id
-          		,denom.campaign_id
-          		,(CAST(num_whole.value as FLOAT) - CAST(num_part.value as FLOAT)) / NULLIF(CAST(denom.value AS FLOAT),0) as calculated_value
+		denom.master_indicator_id
+		,denom.region_id
+		,denom.campaign_id
+		,(CAST(num_whole.value as FLOAT) - CAST(num_part.value as FLOAT)) / NULLIF(CAST(denom.value AS FLOAT),0) as calculated_value
                , CAST(1 AS BOOLEAN) as is_calc
           FROM (
           	SELECT

CREATE FUNCTION fn_calc_datapoint() 
RETURNS TABLE(dwc_id int)
    AS $$ 
	        
    	DROP TABLE IF EXISTS datapoint_with_computed;

    	CREATE TABLE datapoint_with_computed
    	(
    		id SERIAL
    		,indicator_id INTEGER
    		,region_id INTEGER
    		,campaign_id INTEGER
    		,value FLOAT
    		,is_agg BOOLEAN
    		,is_calc BOOLEAN
    	);

    	INSERT INTO datapoint_with_computed
    	(indicator_id,region_id,campaign_id,value,is_agg,is_calc)

    	SELECT

        (indicator_id,region_id,campaign_id,value,is_calc)

        SELECT
		part.indicator_id as master_indicator_id
		,d_part.region_id
		,d_part.campaign_id
		,d_part.value / NULLIF(d_whole.value,0) as value
		,CAST(1 as BOOLEAN) as is_calc
        FROM(
          SELECT max(id) as max_dp_id FROM datapoint_with_computed
        ) x
