Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ek7Ii-00053b-HN for pgsql-performance@arkaria.postgresql.org; Fri, 09 Feb 2018 11:57:09 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.84_2) (envelope-from ) id 1ek7Ih-0005aT-Ku for pgsql-performance@arkaria.postgresql.org; Fri, 09 Feb 2018 11:57:07 +0000 Received: from makus.postgresql.org ([2001:4800:1501:1::229]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1ek7If-0005aJ-Tw for pgsql-performance@lists.postgresql.org; Fri, 09 Feb 2018 11:57:07 +0000 Received: from sonic304-22.consmr.mail.ir2.yahoo.com ([77.238.179.147]) by makus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1ek7IY-0003N5-OD for pgsql-performance@lists.postgresql.org; Fri, 09 Feb 2018 11:57:04 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.gr; s=s2048; t=1518177415; bh=wpCLIm7TZ/Up22UcjZYMMZkPr9RlYH5Syp4ScdACw4k=; h=From:To:Subject:Date:From:Subject; b=pfyAqWw6foZc8h0EOq4s3YFliSaWlGijBwL1TcGNPo5oGNGUaP/a48kLaK1pozHf9mBCqQVRJrHLJoxQJjTFnOLfDxu1PJQ8ImEeVkS2wvlUmvr4Nm7zE37jqMTtKiV/y/xWynrWM8PD2YxhoL7Ib+lbMlv30CT5X3t+daorUog1R2gae5hOuAye8yxjVsufst5C5NcbaGGX8AYFHkIbRq9JtMHohIn1A+kzw+ViCEyKZ5Waw0wW446rHlwdZIF914tuFPX8BwlSIHUDNhOsJ1jJTsWBrtbLFrfpyWyUyaYFBtBGMF4X7TIYqv9msn3omouladbZ7ulzOHWP0h4cZw== X-YMail-OSG: DM3Z6jUVM1l0M8rBpIaLPf6r09qOaeYVchErQwX11RDjvGAbGSwetisApc32SPB 0gI2JcnYuSHDPrsNzGj4EEzPTBgI29b_.ebIBB.bzFW3ggfttEqz8AoGItfy0TShm7O3z_gwvnoW M7IaryvaNrhKYl3v8VKqEEWM52l9e5BfnPlIJEKKVh9VhiSda00MKC7nhexd5_CqfKBIBDVyKNQX so2VIj2pyMTLm6aII1SkCCr.D2VUiPhEOA8t0cHPRnp6N7X.1czYJKhF6uN5Sgkvwe8M2baZzvnV _Mb7RfWoiI_SAG7bMQzbpbH685ZxsppXs_zeXf8dwXqL7898bNDjn3aRI4x_T5mJ5goZZT8g47E4 Lefgxo5B.lVJY4X9VzMLZAhkQfdjVtZljnFvbqs7Ecp3z6aqTXxfBUbnq_.zY8I9fIqRvKwCgpRd IB7cO9FnfGR1ocaWHbpaBHG75b_.3hEogADejqrkqZvhCDZDerHV_V4vYhRZQLBkI05OV3tg1IKy y0l0TFXNOQm0YjswgaLuW7YvW Received: from sonic.gate.mail.ne1.yahoo.com by sonic304.consmr.mail.ir2.yahoo.com with HTTP; Fri, 9 Feb 2018 11:56:55 +0000 Received: from smtp171.mail.ir2.yahoo.com (EHLO EP011) ([46.228.39.38]) by smtp402.mail.ir2.yahoo.com (JAMES SMTP Server ) with ESMTPA ID 932c6330c7e9a6ac5f2e2fbb95c2f962 for ; Fri, 09 Feb 2018 11:56:39 +0000 (UTC) From: "Elias Panagiotidis" To: Subject: Same plans different performance? Date: Fri, 9 Feb 2018 13:56:38 +0200 Message-ID: <047501d3a19d$0b364600$21a2d200$@yahoo.gr> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_NextPart_000_0476_01D3A1AD.CEC18700" X-Mailer: Microsoft Outlook 14.0 Thread-Index: AdOhm36OXlSMWDOiRY6H6Dc4ZENH3w== Content-Language: en-gb List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multipart message in MIME format. ------=_NextPart_000_0476_01D3A1AD.CEC18700 Content-Type: multipart/alternative; boundary="----=_NextPart_001_0477_01D3A1AD.CEC18700" ------=_NextPart_001_0477_01D3A1AD.CEC18700 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi community, I successfully use PG for a while but I am new to the community. I have recently written a number of functions that call each other (one of them is recursive). I attach the code of the top-level (plpgsql) functions in the file sql.sql along with the structure of the main table that is used in their queries. In subsequent runs of the following query (with exactly the same parameters) all the results are the expected ones: SELECT dt.c_create_tree(1::smallint, 13, 1::smallint, 110::smallint, ARRAY[1,2]::smallint[], false, ARRAY[22,8,26,1]::smallint[], true, 100, 4, 0.05); However, before I start the optimizing process (many parts of the code are subject to optimization) I noticed that the performance significantly differs (from 45'' to 7.5') per run and I can't understand what is the trigger that enforces this behavior since the plans are always the same (but not the Heap Blocks and the buffers). I noticed that when I restart the PG's service sometimes (but not always) the first 1 - 5 runs are a lot faster, while, once a run lasts long, all subsequent runs last long too. Also, I noticed that applying ANALYSE of even full VACUM to the main table (pd.d_sample) does not significantly improve the performance if it is already low. The main table on which the queries run is the pd.d_sample that contains around 1.5m rows and the run of the above query updates about 120k of them (the same every time it runs). The two attached logs correspond to excerpts of the EXPLAIN logs of two subsequent runs of the above query the one right after the other. They are pruned because of their size and do not give the total picture, but they cover at least one full iteration and one can see the differences in the Heap Blocks and the buffers from the first few simple queries. My machine has a Core-i7 processor and runs Windows 10. The PG's version is 9.6.3 64bit. I'd appreciate any help to understand the source of the problem and any potential solution. Thanks in advance, Elias ------=_NextPart_001_0477_01D3A1AD.CEC18700 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi = community,

 

I successfully use PG for a while but I am new to the = community.

 

I have recently written a number of functions that = call each other (one of them is recursive). I attach the code of the = top-level (plpgsql) functions in the file sql.sql along with the = structure of the main table that is used in their queries. In subsequent = runs of the following query (with exactly the same parameters) all the = results are the expected ones:

 

SELECT = dt.c_create_tree(1::smallint, 13, 1::smallint, 110::smallint, = ARRAY[1,2]::smallint[], false, ARRAY[22,8,26,1]::smallint[], true, 100, = 4, 0.05);

 

However, before I start the optimizing process (many = parts of the code are subject to optimization) I noticed that the = performance significantly differs (from 45’’ to 7.5’) = per run and I can’t understand what is the trigger that enforces = this behavior since the plans are always the same (but not the Heap = Blocks and the buffers). I noticed that when I restart the PG’s = service sometimes (but not always) the first 1 – 5 runs are a lot = faster, while, once a run lasts long, all subsequent runs last long too. = Also, I noticed that applying ANALYSE of even full VACUM to the main = table (pd.d_sample) does not significantly improve the performance if it = is already low.

 

The main = table on which the queries run is the pd.d_sample that contains around = 1.5m rows and the run of the above query updates about 120k of them (the = same every time it runs).

 

The two = attached logs correspond to excerpts of the EXPLAIN logs of two = subsequent runs of the above query the one right after the other. They = are pruned because of their size and do not give the total picture, but = they cover at least one full iteration and one can see the differences = in the Heap Blocks and the buffers from the first few simple = queries.

 

My machine has a Core-i7 processor and runs Windows = 10. The PG’s version is 9.6.3 64bit.

 

I’d = appreciate any help to understand the source of the problem and any = potential solution.

 

Thanks in = advance,

Elias

------=_NextPart_001_0477_01D3A1AD.CEC18700-- ------=_NextPart_000_0476_01D3A1AD.CEC18700 Content-Type: application/octet-stream; name="explain_slow.log" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="explain_slow.log" 2018-02-09 11:42:01 EET LOG: duration: 704.275 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D128948.73..128948.74 rows=3D1 width=3D16) (actual = time=3D704.267..704.267 rows=3D1 loops=3D1) Buffers: shared hit=3D1589 read=3D41851 written=3D4508 -> Bitmap Heap Scan on d_sample (cost=3D4192.21..128632.34 = rows=3D63278 width=3D8) (actual time=3D41.684..691.035 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: (sample =3D 1) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared hit=3D1589 read=3D41851 written=3D4508 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D28.393..28.393 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1589 read=3D1 2018-02-09 11:42:01 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:01 EET LOG: duration: 599.374 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D128927.77..128927.78 rows=3D1 width=3D32) (actual = time=3D599.368..599.368 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128927.75..128927.77 rows=3D1 width=3D32) = (actual time=3D599.362..599.362 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128924.59 = rows=3D316 width=3D8) (actual time=3D599.317..599.317 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[1] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.497..44.497 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:01 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:02 EET LOG: duration: 591.140 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128619.78..128619.79 rows=3D1 width=3D32) (actual = time=3D591.133..591.134 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128619.76..128619.78 rows=3D1 width=3D32) = (actual time=3D591.129..591.129 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128616.60 = rows=3D316 width=3D8) (actual time=3D591.105..591.105 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.378..47.378 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:02 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:02 EET LOG: duration: 696.853 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129566.64..129566.65 rows=3D1 width=3D32) (actual = time=3D696.844..696.844 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Bitmap Heap Scan on d_sample (cost=3D4192.05..128940.18 = rows=3D62646 width=3D265) (actual time=3D56.989..661.974 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] IS NOT NULL) AND (ind_vars[1] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D1 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D45.267..45.267 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:02 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 819.925 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D140863.14..141153.37 rows=3D10554 width=3D36) = (actual time=3D819.921..819.921 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D9, local hit=3D86 read=3D1 = dirtied=3D1, temp read=3D294 written=3D294 CTE cap2 -> WindowAgg (cost=3D133931.48..137338.77 rows=3D49352 = width=3D48) (actual time=3D790.464..818.807 rows=3D179 loops=3D1) Buffers: shared read=3D43440 written=3D9, temp read=3D294 = written=3D294 -> GroupAggregate (cost=3D133931.48..135734.83 rows=3D49352 = width=3D28) (actual time=3D789.417..818.536 rows=3D179 loops=3D1) Group Key: (d_sample.ind_vars[1]) Buffers: shared read=3D43440 written=3D9, temp = read=3D294 written=3D294 -> Sort (cost=3D133931.48..134088.09 rows=3D62646 = width=3D16) (actual time=3D788.580..801.703 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[1]) Sort Method: external merge Disk: 2344kB Buffers: shared read=3D43440 written=3D9, temp = read=3D294 written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4192.05..128940.18 rows=3D62646 width=3D16) (actual = time=3D58.906..670.092 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] IS NOT NULL) AND = (ind_vars[1] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D9 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.451..46.451 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D3524.37..3814.61 = rows=3D10554 width=3D36) (actual time=3D819.189..819.257 rows=3D87 = loops=3D1) Buffers: shared read=3D43440 written=3D9, temp read=3D294 = written=3D294 -> HashAggregate (cost=3D3524.37..3629.91 rows=3D10554 = width=3D48) (actual time=3D819.182..819.222 rows=3D87 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D9, temp read=3D294 = written=3D294 -> Append (cost=3D3049.44..3366.06 rows=3D10554 = width=3D48) (actual time=3D819.064..819.123 rows=3D87 loops=3D1) Buffers: shared read=3D43440 written=3D9, temp = read=3D294 written=3D294 -> WindowAgg (cost=3D3049.44..3260.50 = rows=3D10553 width=3D48) (actual time=3D819.064..819.111 rows=3D86 = loops=3D1) Buffers: shared read=3D43440 written=3D9, = temp read=3D294 written=3D294 -> Sort (cost=3D3049.44..3075.83 = rows=3D10553 width=3D32) (actual time=3D819.059..819.066 rows=3D86 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 31kB Buffers: shared read=3D43440 = written=3D9, temp read=3D294 written=3D294 -> CTE Scan on cap2 = (cost=3D0.00..2344.22 rows=3D10553 width=3D32) (actual = time=3D790.477..819.026 rows=3D86 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 93 Buffers: shared read=3D43440 = written=3D9, temp read=3D294 written=3D294 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.007..0.007 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:03 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 10.545 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D10.542..10.542 rows=3D1 loops=3D1) Buffers: local hit=3D1 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 11.520 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D11.518..11.518 rows=3D1 loops=3D1) Buffers: local hit=3D3 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 12.562 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D12.560..12.560 rows=3D1 loops=3D1) Buffers: local hit=3D7 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 1.523 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.521..1.521 rows=3D1 loops=3D1) Buffers: local hit=3D7 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 20.893 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D20.890..20.890 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D15 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:03 EET LOG: duration: 2837.582 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2837.579..2837.579 rows=3D1 loops=3D1) Buffers: shared hit=3D277 read=3D173852 dirtied=3D44 written=3D10, = local hit=3D104 read=3D2 dirtied=3D1, temp read=3D294 written=3D294 2018-02-09 11:42:03 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:04 EET LOG: duration: 627.358 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D128927.77..128927.78 rows=3D1 width=3D32) (actual = time=3D627.353..627.354 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D10 InitPlan 1 (returns $0) -> Aggregate (cost=3D128927.75..128927.77 rows=3D1 width=3D32) = (actual time=3D627.348..627.349 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D10 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128924.59 = rows=3D316 width=3D8) (actual time=3D627.328..627.328 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[8] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D10 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.400..46.400 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:04 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:05 EET LOG: duration: 639.034 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128619.78..128619.79 rows=3D1 width=3D32) (actual = time=3D639.028..639.029 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128619.76..128619.78 rows=3D1 width=3D32) = (actual time=3D639.024..639.024 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128616.60 = rows=3D316 width=3D8) (actual time=3D639.001..639.001 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D49.454..49.454 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:05 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:05 EET LOG: duration: 708.236 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129566.64..129566.65 rows=3D1 width=3D32) (actual = time=3D708.229..708.229 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4192.05..128940.18 = rows=3D62646 width=3D265) (actual time=3D64.895..670.432 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D50.054..50.054 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:05 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:06 EET LOG: duration: 866.298 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D140863.14..141153.37 rows=3D10554 width=3D36) = (actual time=3D866.293..866.293 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D2, local hit=3D186 read=3D4 = dirtied=3D2, temp read=3D294 written=3D294 CTE cap2 -> WindowAgg (cost=3D133931.48..137338.77 rows=3D49352 = width=3D48) (actual time=3D833.203..863.756 rows=3D475 loops=3D1) Buffers: shared read=3D43440 written=3D2, temp read=3D294 = written=3D294 -> GroupAggregate (cost=3D133931.48..135734.83 rows=3D49352 = width=3D28) (actual time=3D833.177..863.128 rows=3D475 loops=3D1) Group Key: (d_sample.ind_vars[8]) Buffers: shared read=3D43440 written=3D2, temp = read=3D294 written=3D294 -> Sort (cost=3D133931.48..134088.09 rows=3D62646 = width=3D16) (actual time=3D833.152..845.860 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[8]) Sort Method: external merge Disk: 2344kB Buffers: shared read=3D43440 written=3D2, temp = read=3D294 written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4192.05..128940.18 rows=3D62646 width=3D16) (actual = time=3D61.227..727.018 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D2 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.733..46.733 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D3524.37..3814.61 = rows=3D10554 width=3D36) (actual time=3D864.593..864.713 rows=3D187 = loops=3D1) Buffers: shared read=3D43440 written=3D2, temp read=3D294 = written=3D294 -> HashAggregate (cost=3D3524.37..3629.91 rows=3D10554 = width=3D48) (actual time=3D864.587..864.647 rows=3D187 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D2, temp read=3D294 = written=3D294 -> Append (cost=3D3049.44..3366.06 rows=3D10554 = width=3D48) (actual time=3D864.353..864.478 rows=3D187 loops=3D1) Buffers: shared read=3D43440 written=3D2, temp = read=3D294 written=3D294 -> WindowAgg (cost=3D3049.44..3260.50 = rows=3D10553 width=3D48) (actual time=3D864.352..864.453 rows=3D186 = loops=3D1) Buffers: shared read=3D43440 written=3D2, = temp read=3D294 written=3D294 -> Sort (cost=3D3049.44..3075.83 = rows=3D10553 width=3D32) (actual time=3D864.344..864.356 rows=3D186 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 39kB Buffers: shared read=3D43440 = written=3D2, temp read=3D294 written=3D294 -> CTE Scan on cap2 = (cost=3D0.00..2344.22 rows=3D10553 width=3D32) (actual = time=3D833.290..864.279 rows=3D186 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 289 Buffers: shared read=3D43440 = written=3D2, temp read=3D294 written=3D294 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.010..0.010 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:06 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:06 EET LOG: duration: 1.601 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.601..1.601 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D6 2018-02-09 11:42:06 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:06 EET LOG: duration: 2897.312 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2897.309..2897.309 rows=3D1 loops=3D1) Buffers: shared hit=3D106 read=3D173829 dirtied=3D32 written=3D12, = local hit=3D198 read=3D5 dirtied=3D2, temp read=3D294 written=3D294 2018-02-09 11:42:06 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:07 EET LOG: duration: 614.787 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D128927.77..128927.78 rows=3D1 width=3D32) (actual = time=3D614.782..614.783 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D10 InitPlan 1 (returns $0) -> Aggregate (cost=3D128927.75..128927.77 rows=3D1 width=3D32) = (actual time=3D614.779..614.779 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D10 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128924.59 = rows=3D316 width=3D8) (actual time=3D614.759..614.759 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[22] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D10 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.954..47.954 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:07 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:08 EET LOG: duration: 624.711 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128619.78..128619.79 rows=3D1 width=3D32) (actual = time=3D624.706..624.706 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128619.76..128619.78 rows=3D1 width=3D32) = (actual time=3D624.701..624.701 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128616.60 = rows=3D316 width=3D8) (actual time=3D56.234..613.518 rows=3D77869 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 51865 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.252..44.252 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:08 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:08 EET LOG: duration: 610.471 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129566.64..129566.65 rows=3D1 width=3D32) (actual = time=3D610.463..610.463 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4192.05..128940.18 = rows=3D62646 width=3D265) (actual time=3D321.340..604.463 rows=3D14360 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 115374 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D45.014..45.014 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:08 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:09 EET LOG: duration: 654.871 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D140863.14..141153.37 rows=3D10554 width=3D36) = (actual time=3D654.867..654.867 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D1, local hit=3D204 read=3D3 = dirtied=3D2 CTE cap2 -> WindowAgg (cost=3D133931.48..137338.77 rows=3D49352 = width=3D48) (actual time=3D617.478..641.244 rows=3D12787 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> GroupAggregate (cost=3D133931.48..135734.83 rows=3D49352 = width=3D28) (actual time=3D617.434..626.729 rows=3D12787 loops=3D1) Group Key: (d_sample.ind_vars[22]) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D133931.48..134088.09 rows=3D62646 = width=3D16) (actual time=3D616.804..619.669 rows=3D14360 loops=3D1) Sort Key: (d_sample.ind_vars[22]) Sort Method: quicksort Memory: 1058kB Buffers: shared read=3D43440 written=3D1 -> Bitmap Heap Scan on d_sample = (cost=3D4192.05..128940.18 rows=3D62646 width=3D16) (actual = time=3D322.628..608.416 rows=3D14360 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND = (ind_vars[22] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 115374 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D1 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.704..44.704 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D3524.37..3814.61 = rows=3D10554 width=3D36) (actual time=3D653.669..653.791 rows=3D203 = loops=3D1) Buffers: shared read=3D43440 written=3D1 -> HashAggregate (cost=3D3524.37..3629.91 rows=3D10554 = width=3D48) (actual time=3D653.663..653.721 rows=3D203 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D1 -> Append (cost=3D3049.44..3366.06 rows=3D10554 = width=3D48) (actual time=3D653.433..653.557 rows=3D203 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> WindowAgg (cost=3D3049.44..3260.50 = rows=3D10553 width=3D48) (actual time=3D653.432..653.540 rows=3D202 = loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D3049.44..3075.83 = rows=3D10553 width=3D32) (actual time=3D653.427..653.445 rows=3D202 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 40kB Buffers: shared read=3D43440 = written=3D1 -> CTE Scan on cap2 = (cost=3D0.00..2344.22 rows=3D10553 width=3D32) (actual = time=3D617.487..653.365 rows=3D202 loops=3D1) Filter: ((((sum_defaults / = '244'::double precision) >=3D ((sum_observations)::double precision / = '14360'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '244'::double precision) <=3D ((sum_observations)::double precision / = '14360'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 14360)) Rows Removed by Filter: 12585 Buffers: shared read=3D43440 = written=3D1 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.003 rows=3D1 loops=3D1) 2018-02-09 11:42:09 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:09 EET LOG: duration: 1.435 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.434..1.434 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D6 2018-02-09 11:42:09 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:09 EET LOG: duration: 2544.362 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2544.360..2544.360 rows=3D1 loops=3D1) Buffers: shared hit=3D109 read=3D173828 dirtied=3D28 written=3D11, = local hit=3D216 read=3D4 dirtied=3D2 2018-02-09 11:42:09 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:09 EET LOG: duration: 621.006 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D128927.77..128927.78 rows=3D1 width=3D32) (actual = time=3D621.001..621.001 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D8 InitPlan 1 (returns $0) -> Aggregate (cost=3D128927.75..128927.77 rows=3D1 width=3D32) = (actual time=3D620.997..620.997 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D8 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128924.59 = rows=3D316 width=3D8) (actual time=3D620.976..620.976 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[26] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D8 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D48.145..48.145 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:09 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:10 EET LOG: duration: 604.459 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128619.78..128619.79 rows=3D1 width=3D32) (actual = time=3D604.453..604.453 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 InitPlan 1 (returns $0) -> Aggregate (cost=3D128619.76..128619.78 rows=3D1 width=3D32) = (actual time=3D604.448..604.449 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..128616.60 = rows=3D316 width=3D8) (actual time=3D604.426..604.426 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D5 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.953..45.953 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:10 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:11 EET LOG: duration: 716.119 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129566.64..129566.65 rows=3D1 width=3D32) (actual = time=3D716.111..716.111 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4192.05..128940.18 = rows=3D62646 width=3D265) (actual time=3D55.868..666.057 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D44.141..44.141 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:11 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 1090.922 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D140863.14..141153.37 rows=3D10554 width=3D36) = (actual time=3D1090.918..1090.918 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D1, local hit=3D1499 read=3D14 = dirtied=3D13, temp read=3D294 written=3D892 CTE cap2 -> WindowAgg (cost=3D133931.48..137338.77 rows=3D49352 = width=3D48) (actual time=3D803.495..971.115 rows=3D84582 loops=3D1) Buffers: shared read=3D43440 written=3D1, temp read=3D294 = written=3D294 -> GroupAggregate (cost=3D133931.48..135734.83 rows=3D49352 = width=3D28) (actual time=3D803.469..869.011 rows=3D84582 loops=3D1) Group Key: (d_sample.ind_vars[26]) Buffers: shared read=3D43440 written=3D1, temp = read=3D294 written=3D294 -> Sort (cost=3D133931.48..134088.09 rows=3D62646 = width=3D16) (actual time=3D801.591..818.509 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[26]) Sort Method: external merge Disk: 2344kB Buffers: shared read=3D43440 written=3D1, temp = read=3D294 written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4192.05..128940.18 rows=3D62646 width=3D16) (actual = time=3D58.344..689.777 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND = (ind_vars[26] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D1 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.468..46.468 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D3524.37..3814.61 = rows=3D10554 width=3D36) (actual time=3D1088.277..1089.042 rows=3D1476 = loops=3D1) Buffers: shared read=3D43440 written=3D1, temp read=3D294 = written=3D892 -> HashAggregate (cost=3D3524.37..3629.91 rows=3D10554 = width=3D48) (actual time=3D1088.271..1088.542 rows=3D1476 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D1, temp read=3D294 = written=3D892 -> Append (cost=3D3049.44..3366.06 rows=3D10554 = width=3D48) (actual time=3D1086.635..1087.567 rows=3D1476 loops=3D1) Buffers: shared read=3D43440 written=3D1, temp = read=3D294 written=3D892 -> WindowAgg (cost=3D3049.44..3260.50 = rows=3D10553 width=3D48) (actual time=3D1086.635..1087.451 rows=3D1475 = loops=3D1) Buffers: shared read=3D43440 written=3D1, = temp read=3D294 written=3D892 -> Sort (cost=3D3049.44..3075.83 = rows=3D10553 width=3D32) (actual time=3D1086.627..1086.758 rows=3D1475 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 164kB Buffers: shared read=3D43440 = written=3D1, temp read=3D294 written=3D892 -> CTE Scan on cap2 = (cost=3D0.00..2344.22 rows=3D10553 width=3D32) (actual = time=3D803.505..1086.182 rows=3D1475 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 83107 Buffers: shared read=3D43440 = written=3D1, temp read=3D294 written=3D892 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.008..0.008 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:12 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 1.951 ms plan: Query Text: SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1 Limit (cost=3D16.82..17.43 rows=3D1 width=3D76) (actual = time=3D1.948..1.948 rows=3D1 loops=3D1) Buffers: local hit=3D13 read=3D6 -> Result (cost=3D16.82..21.11 rows=3D7 width=3D76) (actual = time=3D1.946..1.946 rows=3D1 loops=3D1) Buffers: local hit=3D13 read=3D6 -> Sort (cost=3D16.82..16.84 rows=3D7 width=3D60) (actual = time=3D1.834..1.834 rows=3D1 loops=3D1) Sort Key: (CASE WHEN ($12 IS NULL) THEN abs((CASE WHEN = ($23 =3D '0'::double precision) THEN '0'::double precision ELSE = (((cap.sum_defaults)::double precision - $6) / $23) END - = (((cap.sum_observations - $5))::double precision / ($22)::double = precision))) ELSE ($12 * (CASE WHEN ($23 =3D '0'::double precision) THEN = '0'::double precision ELSE (((cap.sum_defaults)::double precision - $6) = / $23) END - (((cap.sum_observations - $5))::double precision / = ($22)::double precision))) END) DESC Sort Method: top-N heapsort Memory: 25kB Buffers: local hit=3D13 read=3D6 -> Bitmap Heap Scan on cap (cost=3D4.35..16.79 rows=3D7 = width=3D60) (actual time=3D0.231..1.504 rows=3D1475 loops=3D1) Recheck Cond: ((point > $2) AND (point <=3D $7)) Heap Blocks: exact=3D13 Buffers: local hit=3D13 read=3D6 -> Bitmap Index Scan on cap_ix (cost=3D0.00..4.35 = rows=3D7 width=3D0) (actual time=3D0.212..0.212 rows=3D1475 loops=3D1) Index Cond: ((point > $2) AND (point <=3D = $7)) Buffers: local read=3D6 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 32 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 1.558 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.556..1.556 rows=3D1 loops=3D1) Buffers: local hit=3D49 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 3.394 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3.393..3.393 rows=3D1 loops=3D1) Buffers: local hit=3D81 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 1.223 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.223..1.223 rows=3D1 loops=3D1) Buffers: local hit=3D47 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 3.142 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3.141..3.141 rows=3D1 loops=3D1) Buffers: local hit=3D80 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 9.727 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D9.726..9.726 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D174 read=3D6 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:12 EET LOG: duration: 3096.477 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3096.475..3096.475 rows=3D1 loops=3D1) Buffers: shared hit=3D111 read=3D173831 dirtied=3D27 written=3D14, = local hit=3D1712 read=3D21 dirtied=3D13, temp read=3D294 written=3D893 2018-02-09 11:42:12 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:13 EET LOG: duration: 647.676 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D129035.25..129035.26 rows=3D1 width=3D16) (actual = time=3D647.668..647.668 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D12 -> Bitmap Heap Scan on d_sample (cost=3D4181.66..128929.79 = rows=3D21093 width=3D8) (actual time=3D61.405..644.126 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D '0.00172989178304991'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D12 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.183..47.183 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:13 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:13 EET LOG: duration: 639.605 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129233.60..129233.61 rows=3D1 width=3D32) (actual = time=3D639.601..639.601 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129233.58..129233.60 rows=3D1 width=3D32) = (actual time=3D639.596..639.596 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129232.53 = rows=3D105 width=3D8) (actual time=3D639.575..639.575 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[8] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.319..46.319 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:13 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:14 EET LOG: duration: 590.210 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128925.61..128925.62 rows=3D1 width=3D32) (actual = time=3D590.204..590.205 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128925.59..128925.61 rows=3D1 width=3D32) = (actual time=3D590.200..590.200 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..128924.54 = rows=3D105 width=3D8) (actual time=3D590.177..590.177 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.371..45.371 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:14 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:14 EET LOG: duration: 638.859 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129446.54..129446.55 rows=3D1 width=3D32) (actual = time=3D638.851..638.851 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4181.61..129237.72 = rows=3D20882 width=3D265) (actual time=3D60.297..633.246 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.761..47.761 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:14 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:15 EET LOG: duration: 639.625 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D133227.47..133340.75 rows=3D4119 width=3D36) = (actual time=3D639.621..639.621 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D1, local hit=3D7 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131398.75..131880.18 rows=3D19257 = width=3D48) (actual time=3D638.313..638.640 rows=3D332 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D131398.75..131446.89 rows=3D19257 = width=3D28) (actual time=3D638.296..638.320 rows=3D332 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 50kB Buffers: shared read=3D43440 written=3D1 -> Subquery Scan on cap1 (cost=3D129498.75..130028.32 = rows=3D19257 width=3D28) (actual time=3D637.960..638.151 rows=3D332 = loops=3D1) Buffers: shared read=3D43440 written=3D1 -> HashAggregate (cost=3D129498.75..129835.75 = rows=3D19257 width=3D28) (actual time=3D637.958..638.122 rows=3D332 = loops=3D1) Group Key: d_sample.ind_vars[8] Buffers: shared read=3D43440 written=3D1 -> Bitmap Heap Scan on d_sample = (cost=3D4181.61..129237.72 rows=3D20882 width=3D16) (actual = time=3D57.168..632.229 rows=3D9896 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 = written=3D1 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.958..44.958 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D1347.30..1460.57 rows=3D4119 = width=3D36) (actual time=3D638.979..639.000 rows=3D7 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> HashAggregate (cost=3D1347.30..1388.49 rows=3D4119 = width=3D48) (actual time=3D638.975..638.990 rows=3D7 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D1 -> Append (cost=3D1161.95..1285.51 rows=3D4119 = width=3D48) (actual time=3D638.951..638.962 rows=3D7 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> WindowAgg (cost=3D1161.95..1244.31 rows=3D4118 = width=3D48) (actual time=3D638.950..638.955 rows=3D6 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D1161.95..1172.24 = rows=3D4118 width=3D32) (actual time=3D638.946..638.947 rows=3D6 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D1 -> CTE Scan on cap2 = (cost=3D0.00..914.71 rows=3D4118 width=3D32) (actual = time=3D638.420..638.940 rows=3D6 loops=3D1) Filter: ((((sum_defaults / = '4'::double precision) >=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '4'::double precision) <=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 9896)) Rows Removed by Filter: 326 Buffers: shared read=3D43440 = written=3D1 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.005 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:15 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:15 EET LOG: duration: 2534.517 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2534.515..2534.515 rows=3D1 loops=3D1) Buffers: shared hit=3D95 read=3D173822 dirtied=3D21 written=3D1, = local hit=3D11 read=3D2 dirtied=3D1 2018-02-09 11:42:15 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:16 EET LOG: duration: 611.864 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129233.60..129233.61 rows=3D1 width=3D32) (actual = time=3D611.859..611.860 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D3 InitPlan 1 (returns $0) -> Aggregate (cost=3D129233.58..129233.60 rows=3D1 width=3D32) = (actual time=3D611.855..611.855 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129232.53 = rows=3D105 width=3D8) (actual time=3D611.834..611.834 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[22] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.608..45.608 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:16 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:16 EET LOG: duration: 629.171 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128925.61..128925.62 rows=3D1 width=3D32) (actual = time=3D629.165..629.165 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128925.59..128925.61 rows=3D1 width=3D32) = (actual time=3D629.160..629.160 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..128924.54 = rows=3D105 width=3D8) (actual time=3D59.759..626.937 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.293..47.293 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:16 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:17 EET LOG: duration: 601.001 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129446.54..129446.55 rows=3D1 width=3D32) (actual = time=3D600.994..600.994 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4181.61..129237.72 = rows=3D20882 width=3D265) (actual time=3D321.279..600.221 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D45.438..45.438 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:17 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:18 EET LOG: duration: 664.529 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D133227.47..133340.75 rows=3D4119 width=3D36) = (actual time=3D664.525..664.525 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D3, local hit=3D4 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131398.75..131880.18 rows=3D19257 = width=3D48) (actual time=3D661.612..662.774 rows=3D586 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D131398.75..131446.89 rows=3D19257 = width=3D28) (actual time=3D661.577..661.667 rows=3D586 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 70kB Buffers: shared read=3D43440 written=3D3 -> Subquery Scan on cap1 (cost=3D129498.75..130028.32 = rows=3D19257 width=3D28) (actual time=3D660.620..661.190 rows=3D586 = loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D129498.75..129835.75 = rows=3D19257 width=3D28) (actual time=3D660.619..661.097 rows=3D586 = loops=3D1) Group Key: d_sample.ind_vars[22] Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample = (cost=3D4181.61..129237.72 rows=3D20882 width=3D16) (actual = time=3D341.783..659.461 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[22] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 = written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D49.418..49.418 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D1347.30..1460.57 rows=3D4119 = width=3D36) (actual time=3D663.686..663.709 rows=3D4 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D1347.30..1388.49 rows=3D4119 = width=3D48) (actual time=3D663.679..663.698 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D3 -> Append (cost=3D1161.95..1285.51 rows=3D4119 = width=3D48) (actual time=3D663.645..663.664 rows=3D4 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> WindowAgg (cost=3D1161.95..1244.31 rows=3D4118 = width=3D48) (actual time=3D663.645..663.654 rows=3D3 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D1161.95..1172.24 = rows=3D4118 width=3D32) (actual time=3D663.638..663.639 rows=3D3 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D3 -> CTE Scan on cap2 = (cost=3D0.00..914.71 rows=3D4118 width=3D32) (actual = time=3D662.066..663.626 rows=3D3 loops=3D1) Filter: ((((sum_defaults / = '1'::double precision) >=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope < slope)) OR (((sum_defaults / = '1'::double precision) <=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope > slope)) OR (sum_observations = =3D 632)) Rows Removed by Filter: 583 Buffers: shared read=3D43440 = written=3D3 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.008..0.008 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:18 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:18 EET LOG: duration: 2527.254 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2527.253..2527.253 rows=3D1 loops=3D1) Buffers: shared hit=3D101 read=3D173825 dirtied=3D23 written=3D6, = local hit=3D8 read=3D2 dirtied=3D1 2018-02-09 11:42:18 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:18 EET LOG: duration: 690.840 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129233.60..129233.61 rows=3D1 width=3D32) (actual = time=3D690.835..690.836 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D7 InitPlan 1 (returns $0) -> Aggregate (cost=3D129233.58..129233.60 rows=3D1 width=3D32) = (actual time=3D690.831..690.832 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D7 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129232.53 = rows=3D105 width=3D8) (actual time=3D690.811..690.811 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[26] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D7 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D60.864..60.864 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:18 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:19 EET LOG: duration: 656.266 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128925.61..128925.62 rows=3D1 width=3D32) (actual = time=3D656.259..656.259 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128925.59..128925.61 rows=3D1 width=3D32) = (actual time=3D656.253..656.253 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..128924.54 = rows=3D105 width=3D8) (actual time=3D656.225..656.225 rows=3D0 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.539..44.539 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:19 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:20 EET LOG: duration: 697.781 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129446.54..129446.55 rows=3D1 width=3D32) (actual = time=3D697.774..697.774 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4181.61..129237.72 = rows=3D20882 width=3D265) (actual time=3D57.746..689.697 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D45.513..45.513 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:20 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:20 EET LOG: duration: 727.140 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D133227.47..133340.75 rows=3D4119 width=3D36) = (actual time=3D727.136..727.136 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D3, local hit=3D8 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131398.75..131880.18 rows=3D19257 = width=3D48) (actual time=3D699.079..714.774 rows=3D9875 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D131398.75..131446.89 rows=3D19257 = width=3D28) (actual time=3D699.056..701.159 rows=3D9875 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 1156kB Buffers: shared read=3D43440 written=3D3 -> Subquery Scan on cap1 (cost=3D129498.75..130028.32 = rows=3D19257 width=3D28) (actual time=3D687.534..693.582 rows=3D9875 = loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D129498.75..129835.75 = rows=3D19257 width=3D28) (actual time=3D687.532..692.531 rows=3D9875 = loops=3D1) Group Key: d_sample.ind_vars[26] Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample = (cost=3D4181.61..129237.72 rows=3D20882 width=3D16) (actual = time=3D57.704..677.675 rows=3D9896 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[26] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 = written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.995..44.995 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D1347.30..1460.57 rows=3D4119 = width=3D36) (actual time=3D726.417..726.439 rows=3D8 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D1347.30..1388.49 rows=3D4119 = width=3D48) (actual time=3D726.411..726.429 rows=3D8 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D3 -> Append (cost=3D1161.95..1285.51 rows=3D4119 = width=3D48) (actual time=3D726.378..726.395 rows=3D8 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> WindowAgg (cost=3D1161.95..1244.31 rows=3D4118 = width=3D48) (actual time=3D726.378..726.385 rows=3D7 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D1161.95..1172.24 = rows=3D4118 width=3D32) (actual time=3D726.370..726.371 rows=3D7 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D3 -> CTE Scan on cap2 = (cost=3D0.00..914.71 rows=3D4118 width=3D32) (actual = time=3D700.221..726.358 rows=3D7 loops=3D1) Filter: ((((sum_defaults / = '4'::double precision) >=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '4'::double precision) <=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 9896)) Rows Removed by Filter: 9868 Buffers: shared read=3D43440 = written=3D3 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.009..0.010 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:20 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:20 EET LOG: duration: 1.135 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.133..1.133 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D1 2018-02-09 11:42:20 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:20 EET LOG: duration: 2792.145 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2792.143..2792.143 rows=3D1 loops=3D1) Buffers: shared hit=3D114 read=3D173830 dirtied=3D20 written=3D10, = local hit=3D12 read=3D2 dirtied=3D1 2018-02-09 11:42:20 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:21 EET LOG: duration: 619.279 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D129269.42..129269.43 rows=3D1 width=3D16) (actual = time=3D619.272..619.272 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D6 -> Bitmap Heap Scan on d_sample (cost=3D4178.15..129234.26 = rows=3D7031 width=3D8) (actual time=3D333.814..618.984 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D '0.00172989178304991'::double = precision) AND (ind_vars[22] <=3D 'Infinity'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D6 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.068..47.068 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:21 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:22 EET LOG: duration: 680.025 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129540.87..129540.88 rows=3D1 width=3D32) (actual = time=3D680.020..680.020 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.85..129540.87 rows=3D1 width=3D32) = (actual time=3D680.015..680.015 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.40..129540.50 = rows=3D35 width=3D8) (actual time=3D679.990..679.990 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1) AND (ind_vars[8] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.357..46.357 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:22 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:22 EET LOG: duration: 652.884 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129232.88..129232.89 rows=3D1 width=3D32) (actual = time=3D652.878..652.878 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.86..129232.88 rows=3D1 width=3D32) = (actual time=3D652.873..652.874 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.40..129232.51 = rows=3D35 width=3D8) (actual time=3D652.851..652.851 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D59.409..59.409 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:22 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:23 EET LOG: duration: 637.848 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129611.84..129611.85 rows=3D1 width=3D32) (actual = time=3D637.840..637.840 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4178.13..129542.23 = rows=3D6961 width=3D265) (actual time=3D328.818..637.270 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[8] <> 'NaN'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.653..47.653 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:23 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:24 EET LOG: duration: 625.409 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D130892.62..130932.47 rows=3D1449 width=3D36) = (actual time=3D625.405..625.405 rows=3D0 loops=3D1) Buffers: shared read=3D43440, local hit=3D4 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129986.52..130429.64 rows=3D6774 width=3D48) = (actual time=3D624.383..624.671 rows=3D50 loops=3D1) Buffers: shared read=3D43440 -> GroupAggregate (cost=3D129986.52..130209.48 rows=3D6774 = width=3D28) (actual time=3D624.360..624.577 rows=3D50 loops=3D1) Group Key: (d_sample.ind_vars[8]) Buffers: shared read=3D43440 -> Sort (cost=3D129986.52..130003.93 rows=3D6961 = width=3D16) (actual time=3D624.342..624.422 rows=3D632 loops=3D1) Sort Key: (d_sample.ind_vars[8]) Sort Method: quicksort Memory: 54kB Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample = (cost=3D4178.13..129542.23 rows=3D6961 width=3D16) (actual = time=3D327.790..623.834 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND = (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[22] <=3D 'Infinity'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.782..46.782 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D462.99..502.83 rows=3D1449 = width=3D36) (actual time=3D624.776..624.784 rows=3D4 loops=3D1) Buffers: shared read=3D43440 -> HashAggregate (cost=3D462.99..477.48 rows=3D1449 = width=3D48) (actual time=3D624.771..624.776 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 -> Append (cost=3D397.78..441.25 rows=3D1449 = width=3D48) (actual time=3D624.750..624.759 rows=3D4 loops=3D1) Buffers: shared read=3D43440 -> WindowAgg (cost=3D397.78..426.74 rows=3D1448 = width=3D48) (actual time=3D624.750..624.753 rows=3D3 loops=3D1) Buffers: shared read=3D43440 -> Sort (cost=3D397.78..401.40 rows=3D1448 = width=3D32) (actual time=3D624.745..624.746 rows=3D3 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 -> CTE Scan on cap2 = (cost=3D0.00..321.76 rows=3D1448 width=3D32) (actual = time=3D624.601..624.736 rows=3D3 loops=3D1) Filter: ((((sum_defaults / = '1'::double precision) >=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope < slope)) OR (((sum_defaults / = '1'::double precision) <=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope > slope)) OR (sum_observations = =3D 632)) Rows Removed by Filter: 47 Buffers: shared read=3D43440 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:24 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:24 EET LOG: duration: 2613.935 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2613.933..2613.933 rows=3D1 loops=3D1) Buffers: shared hit=3D92 read=3D173815 dirtied=3D18, local hit=3D8 = read=3D2 dirtied=3D1 2018-02-09 11:42:24 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:24 EET LOG: duration: 606.587 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129540.87..129540.88 rows=3D1 width=3D32) (actual = time=3D606.583..606.583 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.85..129540.87 rows=3D1 width=3D32) = (actual time=3D606.579..606.579 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 -> Bitmap Heap Scan on d_sample (cost=3D4176.40..129540.50 = rows=3D35 width=3D8) (actual time=3D606.557..606.557 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1) AND (ind_vars[26] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D5 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.352..44.352 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:24 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:25 EET LOG: duration: 614.071 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129232.88..129232.89 rows=3D1 width=3D32) (actual = time=3D614.065..614.065 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.86..129232.88 rows=3D1 width=3D32) = (actual time=3D614.060..614.060 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.40..129232.51 = rows=3D35 width=3D8) (actual time=3D614.039..614.039 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.729..47.729 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:25 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:26 EET LOG: duration: 640.725 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129611.84..129611.85 rows=3D1 width=3D32) (actual = time=3D640.717..640.717 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4178.13..129542.23 = rows=3D6961 width=3D265) (actual time=3D338.679..640.158 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[26] <> 'NaN'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.647..47.647 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:26 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:26 EET LOG: duration: 743.477 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D130892.62..130932.47 rows=3D1449 width=3D36) = (actual time=3D743.471..743.471 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D3, local hit=3D4 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129986.52..130429.64 rows=3D6774 width=3D48) = (actual time=3D736.625..739.089 rows=3D631 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> GroupAggregate (cost=3D129986.52..130209.48 rows=3D6774 = width=3D28) (actual time=3D736.597..737.689 rows=3D631 loops=3D1) Group Key: (d_sample.ind_vars[26]) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D129986.52..130003.93 rows=3D6961 = width=3D16) (actual time=3D736.575..736.797 rows=3D632 loops=3D1) Sort Key: (d_sample.ind_vars[26]) Sort Method: quicksort Memory: 54kB Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample = (cost=3D4178.13..129542.23 rows=3D6961 width=3D16) (actual = time=3D370.289..735.870 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND = (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[22] <=3D 'Infinity'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.090..44.090 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D462.99..502.83 rows=3D1449 = width=3D36) (actual time=3D741.443..741.464 rows=3D4 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D462.99..477.48 rows=3D1449 = width=3D48) (actual time=3D741.435..741.445 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D3 -> Append (cost=3D397.78..441.25 rows=3D1449 = width=3D48) (actual time=3D741.398..741.417 rows=3D4 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> WindowAgg (cost=3D397.78..426.74 rows=3D1448 = width=3D48) (actual time=3D741.398..741.403 rows=3D3 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D397.78..401.40 rows=3D1448 = width=3D32) (actual time=3D741.390..741.391 rows=3D3 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D3 -> CTE Scan on cap2 = (cost=3D0.00..321.76 rows=3D1448 width=3D32) (actual = time=3D736.966..741.378 rows=3D3 loops=3D1) Filter: ((((sum_defaults / = '1'::double precision) >=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope < slope)) OR (((sum_defaults / = '1'::double precision) <=3D ((sum_observations)::double precision / = '632'::double precision)) AND (next_slope > slope)) OR (sum_observations = =3D 632)) Rows Removed by Filter: 628 Buffers: shared read=3D43440 = written=3D3 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.012..0.012 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.003..0.003 rows=3D1 loops=3D1) 2018-02-09 11:42:26 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:26 EET LOG: duration: 1.083 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.081..1.081 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D1 2018-02-09 11:42:26 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:26 EET LOG: duration: 2637.865 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2637.862..2637.862 rows=3D1 loops=3D1) Buffers: shared hit=3D93 read=3D173816 dirtied=3D21 written=3D8, = local hit=3D8 read=3D2 dirtied=3D1 2018-02-09 11:42:26 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:26 EET LOG: duration: 5890.671 ms plan: Query Text: SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D ) Result (cost=3D0.00..0.27 rows=3D1 width=3D32) (actual = time=3D5890.666..5890.667 rows=3D1 loops=3D1) Buffers: shared hit=3D280 read=3D391102 dirtied=3D47 written=3D14, = local hit=3D16 read=3D4 dirtied=3D2 2018-02-09 11:42:26 EET CONTEXT: SQL statement "SELECT = dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:27 EET LOG: duration: 661.238 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D128925.07..128925.08 rows=3D1 width=3D16) (actual = time=3D661.230..661.230 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D2 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..128924.54 = rows=3D105 width=3D8) (actual time=3D63.936..658.795 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D2 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D49.935..49.935 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:27 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:28 EET LOG: duration: 647.656 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129232.53..129232.54 rows=3D1 width=3D32) (actual = time=3D647.651..647.652 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D8 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.51..129232.53 rows=3D1 width=3D32) = (actual time=3D647.647..647.647 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D8 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129232.50 = rows=3D1 width=3D8) (actual time=3D647.626..647.626 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[8] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D8 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D49.025..49.025 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:28 EET LOG: duration: 637.306 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128924.54..128924.55 rows=3D1 width=3D32) (actual = time=3D637.300..637.301 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128924.52..128924.54 rows=3D1 width=3D32) = (actual time=3D637.296..637.296 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..128924.51 = rows=3D1 width=3D8) (actual time=3D637.274..637.274 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[8] IS = NULL) AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.952..46.952 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:29 EET LOG: duration: 640.930 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129233.57..129233.58 rows=3D1 width=3D32) (actual = time=3D640.922..640.922 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129232.53 = rows=3D104 width=3D265) (actual time=3D58.905..635.515 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[8] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D46.679..46.679 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:29 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:30 EET LOG: duration: 656.964 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D129249.31..129249.97 rows=3D24 width=3D36) = (actual time=3D656.960..656.960 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D1, local hit=3D6 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129236.01..129242.77 rows=3D104 width=3D48) = (actual time=3D651.546..655.573 rows=3D329 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> GroupAggregate (cost=3D129236.01..129239.39 rows=3D104 = width=3D28) (actual time=3D651.519..655.163 rows=3D329 loops=3D1) Group Key: (d_sample.ind_vars[8]) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D129236.01..129236.27 rows=3D104 = width=3D16) (actual time=3D651.502..652.855 rows=3D9264 loops=3D1) Sort Key: (d_sample.ind_vars[8]) Sort Method: quicksort Memory: 819kB Buffers: shared read=3D43440 written=3D1 -> Bitmap Heap Scan on d_sample = (cost=3D4176.41..129232.53 rows=3D104 width=3D16) (actual = time=3D62.691..646.941 rows=3D9264 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND = (ind_vars[8] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D1 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D50.096..50.096 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D6.54..7.20 rows=3D24 = width=3D36) (actual time=3D655.962..655.973 rows=3D6 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> HashAggregate (cost=3D6.54..6.78 rows=3D24 width=3D48) = (actual time=3D655.957..655.960 rows=3D6 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D1 -> Append (cost=3D5.46..6.18 rows=3D24 width=3D48) = (actual time=3D655.927..655.943 rows=3D6 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> WindowAgg (cost=3D5.46..5.92 rows=3D23 = width=3D48) (actual time=3D655.926..655.931 rows=3D5 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D5.46..5.52 rows=3D23 = width=3D32) (actual time=3D655.919..655.920 rows=3D5 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D1 -> CTE Scan on cap2 = (cost=3D0.00..4.94 rows=3D23 width=3D32) (actual time=3D651.757..655.909 = rows=3D5 loops=3D1) Filter: ((((sum_defaults / = '3'::double precision) >=3D ((sum_observations)::double precision / = '9264'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '3'::double precision) <=3D ((sum_observations)::double precision / = '9264'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 9264)) Rows Removed by Filter: 324 Buffers: shared read=3D43440 = written=3D1 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.009..0.009 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:30 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:30 EET LOG: duration: 2601.096 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2601.094..2601.094 rows=3D1 loops=3D1) Buffers: shared hit=3D93 read=3D173816 dirtied=3D19 written=3D9, = local hit=3D10 read=3D2 dirtied=3D1 2018-02-09 11:42:30 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:30 EET LOG: duration: 632.809 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129232.53..129232.54 rows=3D1 width=3D32) (actual = time=3D632.803..632.803 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D6 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.51..129232.53 rows=3D1 width=3D32) = (actual time=3D632.799..632.799 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D6 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129232.50 = rows=3D1 width=3D8) (actual time=3D632.778..632.778 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[26] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D6 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.075..47.075 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:30 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:31 EET LOG: duration: 622.665 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D128924.54..128924.55 rows=3D1 width=3D32) (actual = time=3D622.658..622.659 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D128924.52..128924.54 rows=3D1 width=3D32) = (actual time=3D622.654..622.654 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..128924.51 = rows=3D1 width=3D8) (actual time=3D622.632..622.632 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[26] IS = NULL) AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.339..45.339 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:31 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:32 EET LOG: duration: 684.431 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129233.57..129233.58 rows=3D1 width=3D32) (actual = time=3D684.423..684.423 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129232.53 = rows=3D104 width=3D265) (actual time=3D60.834..676.424 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[26] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[26] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.068..47.068 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:32 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:32 EET LOG: duration: 703.862 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D129249.31..129249.97 rows=3D24 width=3D36) = (actual time=3D703.857..703.857 rows=3D0 loops=3D1) Buffers: shared read=3D43440, local hit=3D7 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129236.01..129242.77 rows=3D104 width=3D48) = (actual time=3D675.318..693.946 rows=3D9246 loops=3D1) Buffers: shared read=3D43440 -> GroupAggregate (cost=3D129236.01..129239.39 rows=3D104 = width=3D28) (actual time=3D675.293..682.654 rows=3D9246 loops=3D1) Group Key: (d_sample.ind_vars[26]) Buffers: shared read=3D43440 -> Sort (cost=3D129236.01..129236.27 rows=3D104 = width=3D16) (actual time=3D675.275..677.232 rows=3D9264 loops=3D1) Sort Key: (d_sample.ind_vars[26]) Sort Method: quicksort Memory: 819kB Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample = (cost=3D4176.41..129232.53 rows=3D104 width=3D16) (actual = time=3D60.006..668.906 rows=3D9264 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND = (ind_vars[26] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.311..47.311 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D6.54..7.20 rows=3D24 = width=3D36) (actual time=3D703.201..703.208 rows=3D7 loops=3D1) Buffers: shared read=3D43440 -> HashAggregate (cost=3D6.54..6.78 rows=3D24 width=3D48) = (actual time=3D703.195..703.198 rows=3D7 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 -> Append (cost=3D5.46..6.18 rows=3D24 width=3D48) = (actual time=3D703.168..703.182 rows=3D7 loops=3D1) Buffers: shared read=3D43440 -> WindowAgg (cost=3D5.46..5.92 rows=3D23 = width=3D48) (actual time=3D703.167..703.171 rows=3D6 loops=3D1) Buffers: shared read=3D43440 -> Sort (cost=3D5.46..5.52 rows=3D23 = width=3D32) (actual time=3D703.162..703.162 rows=3D6 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 -> CTE Scan on cap2 = (cost=3D0.00..4.94 rows=3D23 width=3D32) (actual time=3D679.227..703.151 = rows=3D6 loops=3D1) Filter: ((((sum_defaults / = '3'::double precision) >=3D ((sum_observations)::double precision / = '9264'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '3'::double precision) <=3D ((sum_observations)::double precision / = '9264'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 9264)) Rows Removed by Filter: 9240 Buffers: shared read=3D43440 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.009..0.009 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:32 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:32 EET LOG: duration: 2661.338 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2661.336..2661.336 rows=3D1 loops=3D1) Buffers: shared hit=3D99 read=3D173811 dirtied=3D18 written=3D6, = local hit=3D11 read=3D2 dirtied=3D1 2018-02-09 11:42:32 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:32 EET LOG: duration: 5938.928 ms plan: Query Text: SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D ) Result (cost=3D0.00..0.27 rows=3D1 width=3D32) (actual = time=3D5938.923..5938.923 rows=3D1 loops=3D1) Buffers: shared hit=3D284 read=3D391098 dirtied=3D45 written=3D17, = local hit=3D21 read=3D4 dirtied=3D2 2018-02-09 11:42:32 EET CONTEXT: SQL statement "SELECT = dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:33 EET LOG: duration: 654.660 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D129234.16..129234.17 rows=3D1 width=3D16) (actual = time=3D654.652..654.652 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D13 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..129232.58 = rows=3D316 width=3D8) (actual time=3D59.843..651.782 rows=3D10703 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D13 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D46.342..46.342 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:33 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:34 EET LOG: duration: 627.670 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129540.53..129540.54 rows=3D1 width=3D32) (actual = time=3D627.666..627.666 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D7 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.51..129540.53 rows=3D1 width=3D32) = (actual time=3D627.661..627.661 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D7 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129540.49 = rows=3D2 width=3D8) (actual time=3D627.641..627.641 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1) AND (ind_vars[8] =3D 'NaN'::double = precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D7 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D48.137..48.137 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:34 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:34 EET LOG: duration: 604.532 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129232.54..129232.55 rows=3D1 width=3D32) (actual = time=3D604.526..604.526 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.52..129232.54 rows=3D1 width=3D32) = (actual time=3D604.522..604.522 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129232.50 = rows=3D2 width=3D8) (actual time=3D604.499..604.499 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.731..45.731 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:34 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:35 EET LOG: duration: 643.801 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129543.70..129543.71 rows=3D1 width=3D32) (actual = time=3D643.795..643.795 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..129540.57 = rows=3D313 width=3D265) (actual time=3D59.263..637.695 rows=3D10703 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D46.357..46.357 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:35 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:36 EET LOG: duration: 651.769 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D129593.85..129595.72 rows=3D68 width=3D36) = (actual time=3D651.765..651.765 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D1, local hit=3D15 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129553.55..129573.89 rows=3D313 width=3D48) = (actual time=3D646.718..650.674 rows=3D381 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> GroupAggregate (cost=3D129553.55..129563.72 rows=3D313 = width=3D28) (actual time=3D646.693..650.191 rows=3D381 loops=3D1) Group Key: (d_sample.ind_vars[8]) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D129553.55..129554.33 rows=3D313 = width=3D16) (actual time=3D646.676..648.023 rows=3D10703 loops=3D1) Sort Key: (d_sample.ind_vars[8]) Sort Method: quicksort Memory: 886kB Buffers: shared read=3D43440 written=3D1 -> Bitmap Heap Scan on d_sample = (cost=3D4176.47..129540.57 rows=3D313 width=3D16) (actual = time=3D60.275..642.479 rows=3D10703 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND = (ind_vars[1] > '0.00172989178304991'::double precision) AND (ind_vars[1] = <=3D '0.00363416191114579'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D1 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.474..46.474 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D19.96..21.83 rows=3D68 = width=3D36) (actual time=3D651.122..651.133 rows=3D15 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> HashAggregate (cost=3D19.96..20.64 rows=3D68 width=3D48) = (actual time=3D651.116..651.120 rows=3D15 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D1 -> Append (cost=3D16.90..18.94 rows=3D68 width=3D48) = (actual time=3D651.083..651.099 rows=3D15 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> WindowAgg (cost=3D16.90..18.24 rows=3D67 = width=3D48) (actual time=3D651.083..651.091 rows=3D14 loops=3D1) Buffers: shared read=3D43440 written=3D1 -> Sort (cost=3D16.90..17.07 rows=3D67 = width=3D32) (actual time=3D651.078..651.079 rows=3D14 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 26kB Buffers: shared read=3D43440 = written=3D1 -> CTE Scan on cap2 = (cost=3D0.00..14.87 rows=3D67 width=3D32) (actual = time=3D646.946..651.067 rows=3D14 loops=3D1) Filter: ((((sum_defaults / = '21'::double precision) >=3D ((sum_observations)::double precision / = '10703'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '21'::double precision) <=3D ((sum_observations)::double precision / = '10703'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 10703)) Rows Removed by Filter: 367 Buffers: shared read=3D43440 = written=3D1 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:36 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:36 EET LOG: duration: 2544.694 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2544.692..2544.692 rows=3D1 loops=3D1) Buffers: shared hit=3D110 read=3D173826 dirtied=3D20 written=3D8, = local hit=3D19 read=3D2 dirtied=3D1 2018-02-09 11:42:36 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:36 EET LOG: duration: 615.388 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129540.53..129540.54 rows=3D1 width=3D32) (actual = time=3D615.383..615.384 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.51..129540.53 rows=3D1 width=3D32) = (actual time=3D615.379..615.380 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D5 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129540.49 = rows=3D2 width=3D8) (actual time=3D615.358..615.358 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1) AND (ind_vars[22] =3D 'NaN'::double = precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D5 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D44.707..44.707 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:36 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:37 EET LOG: duration: 628.397 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129232.54..129232.55 rows=3D1 width=3D32) (actual = time=3D628.391..628.392 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.52..129232.54 rows=3D1 width=3D32) = (actual time=3D628.387..628.387 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129232.50 = rows=3D2 width=3D8) (actual time=3D58.209..626.164 rows=3D9168 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120566 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.377..45.377 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:37 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:37 EET LOG: duration: 600.412 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129543.70..129543.71 rows=3D1 width=3D32) (actual = time=3D600.405..600.405 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..129540.57 = rows=3D313 width=3D265) (actual time=3D321.566..599.207 rows=3D1535 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 128199 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D47.556..47.556 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:37 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:38 EET LOG: duration: 607.397 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D129593.85..129595.72 rows=3D68 width=3D36) = (actual time=3D607.393..607.393 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D3, local hit=3D3 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129553.55..129573.89 rows=3D313 width=3D48) = (actual time=3D602.750..605.373 rows=3D1386 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> GroupAggregate (cost=3D129553.55..129563.72 rows=3D313 = width=3D28) (actual time=3D602.726..603.736 rows=3D1386 loops=3D1) Group Key: (d_sample.ind_vars[22]) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D129553.55..129554.33 rows=3D313 = width=3D16) (actual time=3D602.653..602.891 rows=3D1535 loops=3D1) Sort Key: (d_sample.ind_vars[22]) Sort Method: quicksort Memory: 120kB Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample = (cost=3D4176.47..129540.57 rows=3D313 width=3D16) (actual = time=3D323.771..601.533 rows=3D1535 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND = (ind_vars[1] > '0.00172989178304991'::double precision) AND (ind_vars[1] = <=3D '0.00363416191114579'::double precision) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 128199 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.880..45.880 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D19.96..21.83 rows=3D68 = width=3D36) (actual time=3D606.769..606.774 rows=3D3 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D19.96..20.64 rows=3D68 width=3D48) = (actual time=3D606.763..606.765 rows=3D3 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D3 -> Append (cost=3D16.90..18.94 rows=3D68 width=3D48) = (actual time=3D606.745..606.754 rows=3D3 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> WindowAgg (cost=3D16.90..18.24 rows=3D67 = width=3D48) (actual time=3D606.745..606.747 rows=3D2 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D16.90..17.07 rows=3D67 = width=3D32) (actual time=3D606.740..606.740 rows=3D2 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared read=3D43440 = written=3D3 -> CTE Scan on cap2 = (cost=3D0.00..14.87 rows=3D67 width=3D32) (actual = time=3D602.758..606.733 rows=3D2 loops=3D1) Filter: ((((sum_defaults / = '1'::double precision) >=3D ((sum_observations)::double precision / = '1535'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1'::double precision) <=3D ((sum_observations)::double precision / = '1535'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 1535)) Rows Removed by Filter: 1384 Buffers: shared read=3D43440 = written=3D3 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.005 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:38 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:38 EET LOG: duration: 1.071 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.070..1.070 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D3 2018-02-09 11:42:38 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:38 EET LOG: duration: 2470.058 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2470.056..2470.056 rows=3D1 loops=3D1) Buffers: shared hit=3D107 read=3D173823 dirtied=3D20 written=3D8, = local hit=3D9 read=3D2 dirtied=3D1 2018-02-09 11:42:38 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:39 EET LOG: duration: 631.682 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129540.53..129540.54 rows=3D1 width=3D32) (actual = time=3D631.678..631.678 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D6 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.51..129540.53 rows=3D1 width=3D32) = (actual time=3D631.674..631.674 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D6 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129540.49 = rows=3D2 width=3D8) (actual time=3D631.652..631.652 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1) AND (ind_vars[26] =3D 'NaN'::double = precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D6 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D46.891..46.891 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:39 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:39 EET LOG: duration: 599.051 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129232.54..129232.55 rows=3D1 width=3D32) (actual = time=3D599.046..599.046 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129232.52..129232.54 rows=3D1 width=3D32) = (actual time=3D599.041..599.042 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129232.50 = rows=3D2 width=3D8) (actual time=3D599.020..599.020 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.290..45.290 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:39 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:40 EET LOG: duration: 668.510 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D129543.70..129543.71 rows=3D1 width=3D32) (actual = time=3D668.503..668.503 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.47..129540.57 = rows=3D313 width=3D265) (actual time=3D57.354..660.861 rows=3D10703 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D44.076..44.076 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:40 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:41 EET LOG: duration: 695.468 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D129593.85..129595.72 rows=3D68 width=3D36) = (actual time=3D695.464..695.464 rows=3D0 loops=3D1) Buffers: shared read=3D43440 written=3D3, local hit=3D22 read=3D1 = dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D129553.55..129573.89 rows=3D313 width=3D48) = (actual time=3D663.284..684.224 rows=3D10518 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> GroupAggregate (cost=3D129553.55..129563.72 rows=3D313 = width=3D28) (actual time=3D663.260..671.321 rows=3D10518 loops=3D1) Group Key: (d_sample.ind_vars[26]) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D129553.55..129554.33 rows=3D313 = width=3D16) (actual time=3D663.172..665.054 rows=3D10703 loops=3D1) Sort Key: (d_sample.ind_vars[26]) Sort Method: quicksort Memory: 886kB Buffers: shared read=3D43440 written=3D3 -> Bitmap Heap Scan on d_sample = (cost=3D4176.47..129540.57 rows=3D313 width=3D16) (actual = time=3D60.385..655.771 rows=3D10703 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND = (ind_vars[1] > '0.00172989178304991'::double precision) AND (ind_vars[1] = <=3D '0.00363416191114579'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D3 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D45.825..45.825 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared read=3D1590 -> Subquery Scan on "*SELECT*" (cost=3D19.96..21.83 rows=3D68 = width=3D36) (actual time=3D694.802..694.815 rows=3D22 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> HashAggregate (cost=3D19.96..20.64 rows=3D68 width=3D48) = (actual time=3D694.796..694.801 rows=3D22 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared read=3D43440 written=3D3 -> Append (cost=3D16.90..18.94 rows=3D68 width=3D48) = (actual time=3D694.757..694.778 rows=3D22 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> WindowAgg (cost=3D16.90..18.24 rows=3D67 = width=3D48) (actual time=3D694.756..694.769 rows=3D21 loops=3D1) Buffers: shared read=3D43440 written=3D3 -> Sort (cost=3D16.90..17.07 rows=3D67 = width=3D32) (actual time=3D694.751..694.752 rows=3D21 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 26kB Buffers: shared read=3D43440 = written=3D3 -> CTE Scan on cap2 = (cost=3D0.00..14.87 rows=3D67 width=3D32) (actual = time=3D663.294..694.738 rows=3D21 loops=3D1) Filter: ((((sum_defaults / = '21'::double precision) >=3D ((sum_observations)::double precision / = '10703'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '21'::double precision) <=3D ((sum_observations)::double precision / = '10703'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 10703)) Rows Removed by Filter: 10497 Buffers: shared read=3D43440 = written=3D3 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:42:41 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:41 EET LOG: duration: 1.643 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.642..1.642 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D3 2018-02-09 11:42:41 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:41 EET LOG: duration: 2613.207 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D2613.205..2613.205 rows=3D1 loops=3D1) Buffers: shared hit=3D107 read=3D173825 dirtied=3D21 written=3D9, = local hit=3D28 read=3D2 dirtied=3D1 2018-02-09 11:42:41 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:41 EET LOG: duration: 627.879 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D129541.05..129541.06 rows=3D1 width=3D16) (actual = time=3D627.872..627.872 rows=3D1 loops=3D1) Buffers: shared read=3D43440 written=3D11 -> Bitmap Heap Scan on d_sample (cost=3D4176.41..129540.52 = rows=3D105 width=3D8) (actual time=3D58.122..627.119 rows=3D2071 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (ind_vars[26] <=3D '2.13297738591316'::double precision) = AND (sample =3D 1)) Rows Removed by Filter: 127663 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 written=3D11 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4176.39 = rows=3D123196 width=3D0) (actual time=3D45.163..45.163 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared read=3D1590 2018-02-09 11:42:41 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:42 EET LOG: duration: 631.369 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D129848.51..129848.52 rows=3D1 width=3D32) (actual = time=3D631.364..631.364 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129848.49..129848.51 rows=3D1 width=3D32) = (actual time=3D631.360..631.360 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129848.48 = rows=3D1 width=3D8) (actual time=3D631.339..631.339 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (ind_vars[26] <=3D '2.13297738591316'::double precision) = AND (sample =3D 1) AND (ind_vars[8] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.426..47.426 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 2018-02-09 11:42:42 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:42:42 EET LOG: duration: 615.997 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129540.52..129540.53 rows=3D1 width=3D32) (actual = time=3D615.991..615.992 rows=3D1 loops=3D1) Buffers: shared read=3D43440 InitPlan 1 (returns $0) -> Aggregate (cost=3D129540.50..129540.52 rows=3D1 width=3D32) = (actual time=3D615.986..615.986 rows=3D1 loops=3D1) Buffers: shared read=3D43440 -> Bitmap Heap Scan on d_sample (cost=3D4176.39..129540.49 = rows=3D1 width=3D8) (actual time=3D615.964..615.964 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[26] <=3D = '2.13297738591316'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D41850 Buffers: shared read=3D43440 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4176.39 rows=3D123196 width=3D0) (actual = time=3D47.885..47.885 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared read=3D1590 ------=_NextPart_000_0476_01D3A1AD.CEC18700 Content-Type: application/octet-stream; name="explain_fast.log" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="explain_fast.log" 2018-02-09 11:34:24 EET LOG: duration: 221.230 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D130035.48..130035.49 rows=3D1 width=3D16) (actual = time=3D221.222..221.222 rows=3D1 loops=3D1) Buffers: shared hit=3D3 read=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4294.14..129695.20 = rows=3D68056 width=3D8) (actual time=3D47.143..209.384 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: (sample =3D 1) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D3 read=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D45.559..45.559 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D3 read=3D1588 2018-02-09 11:34:24 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:24 EET LOG: duration: 62.707 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130010.86..130010.87 rows=3D1 width=3D32) (actual = time=3D62.701..62.701 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130010.84..130010.86 rows=3D1 width=3D32) = (actual time=3D62.683..62.683 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130007.44 = rows=3D340 width=3D8) (actual time=3D62.661..62.661 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[1] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.870..14.870 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:24 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:24 EET LOG: duration: 53.390 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129681.69..129681.70 rows=3D1 width=3D32) (actual = time=3D53.384..53.385 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D129681.67..129681.69 rows=3D1 width=3D32) = (actual time=3D53.365..53.366 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..129678.27 = rows=3D340 width=3D8) (actual time=3D53.342..53.342 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.960..14.960 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:24 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:24 EET LOG: duration: 109.670 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130697.97..130697.98 rows=3D1 width=3D32) (actual = time=3D109.661..109.661 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4293.97..130024.20 = rows=3D67377 width=3D267) (actual time=3D16.025..80.158 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] IS NOT NULL) AND (ind_vars[1] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.746..14.746 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:24 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 219.323 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D142859.01..143169.74 rows=3D11299 width=3D36) = (actual time=3D219.319..219.319 rows=3D0 loops=3D1) Buffers: shared hit=3D9279, local hit=3D86 read=3D1 dirtied=3D1, temp = read=3D294 written=3D294 CTE cap2 -> WindowAgg (cost=3D135427.83..139080.28 rows=3D52836 = width=3D48) (actual time=3D190.747..218.022 rows=3D179 loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 written=3D294 -> GroupAggregate (cost=3D135427.83..137363.11 rows=3D52836 = width=3D28) (actual time=3D189.798..217.709 rows=3D179 loops=3D1) Group Key: (d_sample.ind_vars[1]) Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Sort (cost=3D135427.83..135596.27 rows=3D67377 = width=3D16) (actual time=3D189.051..201.366 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[1]) Sort Method: external merge Disk: 2344kB Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4293.97..130024.20 rows=3D67377 width=3D16) (actual = time=3D15.513..89.515 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] IS NOT NULL) AND = (ind_vars[1] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.284..14.284 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D3778.73..4089.45 = rows=3D11299 width=3D36) (actual time=3D218.467..218.531 rows=3D87 = loops=3D1) Buffers: shared hit=3D9279, temp read=3D294 written=3D294 -> HashAggregate (cost=3D3778.73..3891.72 rows=3D11299 = width=3D48) (actual time=3D218.459..218.496 rows=3D87 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9279, temp read=3D294 written=3D294 -> Append (cost=3D3270.28..3609.25 rows=3D11299 = width=3D48) (actual time=3D218.340..218.404 rows=3D87 loops=3D1) Buffers: shared hit=3D9279, temp read=3D294 = written=3D294 -> WindowAgg (cost=3D3270.28..3496.24 = rows=3D11298 width=3D48) (actual time=3D218.340..218.389 rows=3D86 = loops=3D1) Buffers: shared hit=3D9279, temp read=3D294 = written=3D294 -> Sort (cost=3D3270.28..3298.52 = rows=3D11298 width=3D32) (actual time=3D218.333..218.341 rows=3D86 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 31kB Buffers: shared hit=3D9279, temp = read=3D294 written=3D294 -> CTE Scan on cap2 = (cost=3D0.00..2509.71 rows=3D11298 width=3D32) (actual = time=3D190.760..218.233 rows=3D86 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 93 Buffers: shared hit=3D9276, temp = read=3D294 written=3D294 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.007..0.007 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.003..0.003 rows=3D1 loops=3D1) 2018-02-09 11:34:25 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 25.591 ms plan: Query Text: SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1 Limit (cost=3D4.92..5.47 rows=3D1 width=3D76) (actual = time=3D25.585..25.585 rows=3D1 loops=3D1) Buffers: shared hit=3D31 read=3D3, local hit=3D1 -> Result (cost=3D4.92..53.42 rows=3D87 width=3D76) (actual = time=3D25.581..25.581 rows=3D1 loops=3D1) Buffers: shared hit=3D31 read=3D3, local hit=3D1 -> Sort (cost=3D4.92..5.13 rows=3D87 width=3D60) (actual = time=3D0.132..0.132 rows=3D1 loops=3D1) Sort Key: (('-1'::double precision * = ((((cap.sum_defaults)::double precision - '0'::double precision) / = '1887'::double precision) - (((cap.sum_observations - 0))::double = precision / '92229'::double precision)))) DESC Sort Method: top-N heapsort Memory: 25kB Buffers: local hit=3D1 -> Seq Scan on cap (cost=3D0.00..4.48 rows=3D87 = width=3D60) (actual time=3D0.026..0.096 rows=3D86 loops=3D1) Filter: ((point > 0) AND (point <=3D 86)) Rows Removed by Filter: 1 Buffers: local hit=3D1 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 32 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 5.947 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D5.943..5.943 rows=3D1 loops=3D1) Buffers: shared hit=3D31 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 12.475 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D12.474..12.474 rows=3D1 loops=3D1) Buffers: shared hit=3D31, local hit=3D3 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 13.839 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D13.837..13.837 rows=3D1 loops=3D1) Buffers: shared hit=3D31, local hit=3D7 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 15.610 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D15.604..15.604 rows=3D1 loops=3D1) Buffers: shared hit=3D31, local hit=3D13 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 1.429 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.428..1.428 rows=3D1 loops=3D1) Buffers: local hit=3D7 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 81.202 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D81.197..81.197 rows=3D1 loops=3D1) Buffers: shared hit=3D274 read=3D6, local hit=3D24 read=3D1 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 703.062 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D703.060..703.060 rows=3D1 loops=3D1) Buffers: shared hit=3D38121 read=3D27 dirtied=3D13, local hit=3D113 = read=3D3 dirtied=3D1, temp read=3D294 written=3D294 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 63.142 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130010.86..130010.87 rows=3D1 width=3D32) (actual = time=3D63.138..63.138 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130010.84..130010.86 rows=3D1 width=3D32) = (actual time=3D63.133..63.134 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130007.44 = rows=3D340 width=3D8) (actual time=3D63.113..63.113 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[8] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.182..14.182 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 56.249 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129681.69..129681.70 rows=3D1 width=3D32) (actual = time=3D56.244..56.244 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D129681.67..129681.69 rows=3D1 width=3D32) = (actual time=3D56.239..56.240 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..129678.27 = rows=3D340 width=3D8) (actual time=3D56.217..56.217 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.910..14.910 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 124.447 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130697.97..130697.98 rows=3D1 width=3D32) (actual = time=3D124.439..124.439 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4293.97..130024.20 = rows=3D67377 width=3D267) (actual time=3D15.850..90.184 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.418..14.418 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 227.579 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D142859.01..143169.74 rows=3D11299 width=3D36) = (actual time=3D227.576..227.576 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D186 read=3D4 dirtied=3D2, = temp read=3D294 written=3D294 CTE cap2 -> WindowAgg (cost=3D135427.83..139080.28 rows=3D52836 = width=3D48) (actual time=3D195.827..225.008 rows=3D475 loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 written=3D294 -> GroupAggregate (cost=3D135427.83..137363.11 rows=3D52836 = width=3D28) (actual time=3D195.791..224.412 rows=3D475 loops=3D1) Group Key: (d_sample.ind_vars[8]) Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Sort (cost=3D135427.83..135596.27 rows=3D67377 = width=3D16) (actual time=3D195.768..208.315 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[8]) Sort Method: external merge Disk: 2344kB Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4293.97..130024.20 rows=3D67377 width=3D16) (actual = time=3D15.784..102.236 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.507..14.507 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D3778.73..4089.45 = rows=3D11299 width=3D36) (actual time=3D225.797..225.919 rows=3D187 = loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 written=3D294 -> HashAggregate (cost=3D3778.73..3891.72 rows=3D11299 = width=3D48) (actual time=3D225.792..225.852 rows=3D187 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276, temp read=3D294 written=3D294 -> Append (cost=3D3270.28..3609.25 rows=3D11299 = width=3D48) (actual time=3D225.558..225.689 rows=3D187 loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> WindowAgg (cost=3D3270.28..3496.24 = rows=3D11298 width=3D48) (actual time=3D225.558..225.665 rows=3D186 = loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Sort (cost=3D3270.28..3298.52 = rows=3D11298 width=3D32) (actual time=3D225.550..225.567 rows=3D186 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 39kB Buffers: shared hit=3D9276, temp = read=3D294 written=3D294 -> CTE Scan on cap2 = (cost=3D0.00..2509.71 rows=3D11298 width=3D32) (actual = time=3D195.907..225.484 rows=3D186 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 289 Buffers: shared hit=3D9276, temp = read=3D294 written=3D294 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.010..0.010 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:25 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 1.346 ms plan: Query Text: SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1 Limit (cost=3D4.89..5.51 rows=3D1 width=3D76) (actual = time=3D1.344..1.344 rows=3D1 loops=3D1) Buffers: shared hit=3D30, local hit=3D2 -> Result (cost=3D4.89..5.51 rows=3D1 width=3D76) (actual = time=3D1.342..1.342 rows=3D1 loops=3D1) Buffers: shared hit=3D30, local hit=3D2 -> Sort (cost=3D4.89..4.90 rows=3D1 width=3D60) (actual = time=3D0.174..0.174 rows=3D1 loops=3D1) Sort Key: (CASE WHEN ($12 IS NULL) THEN abs((CASE WHEN = ($23 =3D '0'::double precision) THEN '0'::double precision ELSE = (((cap.sum_defaults)::double precision - $6) / $23) END - = (((cap.sum_observations - $5))::double precision / ($22)::double = precision))) ELSE ($12 * (CASE WHEN ($23 =3D '0'::double precision) THEN = '0'::double precision ELSE (((cap.sum_defaults)::double precision - $6) = / $23) END - (((cap.sum_observations - $5))::double precision / = ($22)::double precision))) END) DESC Sort Method: top-N heapsort Memory: 25kB Buffers: local hit=3D2 -> Seq Scan on cap (cost=3D0.00..4.88 rows=3D1 = width=3D60) (actual time=3D0.019..0.145 rows=3D135 loops=3D1) Filter: ((point > $2) AND (point <=3D $7)) Rows Removed by Filter: 52 Buffers: local hit=3D2 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 32 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 1.830 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.828..1.828 rows=3D1 loops=3D1) Buffers: shared hit=3D30, local hit=3D2 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 3.143 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3.142..3.142 rows=3D1 loops=3D1) Buffers: shared hit=3D45, local hit=3D6 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 507.733 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D507.731..507.731 rows=3D1 loops=3D1) Buffers: shared hit=3D37336 read=3D4, local hit=3D198 read=3D5 = dirtied=3D2, temp read=3D294 written=3D294 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:25 EET LOG: duration: 60.408 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130010.86..130010.87 rows=3D1 width=3D32) (actual = time=3D60.401..60.402 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130010.84..130010.86 rows=3D1 width=3D32) = (actual time=3D60.396..60.396 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130007.44 = rows=3D340 width=3D8) (actual time=3D60.364..60.364 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[22] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.269..15.269 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:25 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 68.653 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129681.69..129681.70 rows=3D1 width=3D32) (actual = time=3D68.646..68.647 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D129681.67..129681.69 rows=3D1 width=3D32) = (actual time=3D68.641..68.641 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..129678.27 = rows=3D340 width=3D8) (actual time=3D15.427..61.041 rows=3D77869 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 51865 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.212..14.212 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 60.725 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130697.97..130697.98 rows=3D1 width=3D32) (actual = time=3D60.718..60.718 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4293.97..130024.20 = rows=3D67377 width=3D267) (actual time=3D24.740..56.035 rows=3D14360 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 115374 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.033..14.033 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 103.409 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D142859.01..143169.74 rows=3D11299 width=3D36) = (actual time=3D103.405..103.405 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D204 read=3D3 dirtied=3D2 CTE cap2 -> WindowAgg (cost=3D135427.83..139080.28 rows=3D52836 = width=3D48) (actual time=3D65.224..89.581 rows=3D12787 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D135427.83..137363.11 rows=3D52836 = width=3D28) (actual time=3D65.200..74.850 rows=3D12787 loops=3D1) Group Key: (d_sample.ind_vars[22]) Buffers: shared hit=3D9276 -> Sort (cost=3D135427.83..135596.27 rows=3D67377 = width=3D16) (actual time=3D64.601..67.409 rows=3D14360 loops=3D1) Sort Key: (d_sample.ind_vars[22]) Sort Method: quicksort Memory: 1058kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4293.97..130024.20 rows=3D67377 width=3D16) (actual = time=3D24.962..57.907 rows=3D14360 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND = (ind_vars[22] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 115374 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.288..14.288 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D3778.73..4089.45 = rows=3D11299 width=3D36) (actual time=3D102.217..102.337 rows=3D203 = loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D3778.73..3891.72 rows=3D11299 = width=3D48) (actual time=3D102.210..102.269 rows=3D203 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D3270.28..3609.25 rows=3D11299 = width=3D48) (actual time=3D101.961..102.095 rows=3D203 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D3270.28..3496.24 = rows=3D11298 width=3D48) (actual time=3D101.961..102.071 rows=3D202 = loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D3270.28..3298.52 = rows=3D11298 width=3D32) (actual time=3D101.954..101.971 rows=3D202 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 40kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..2509.71 rows=3D11298 width=3D32) (actual = time=3D65.233..101.884 rows=3D202 loops=3D1) Filter: ((((sum_defaults / = '244'::double precision) >=3D ((sum_observations)::double precision / = '14360'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '244'::double precision) <=3D ((sum_observations)::double precision / = '14360'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 14360)) Rows Removed by Filter: 12585 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.007..0.007 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:26 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 1.486 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.485..1.485 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D6 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 338.028 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D338.027..338.027 rows=3D1 loops=3D1) Buffers: shared hit=3D37276 read=3D3 dirtied=3D3, local hit=3D216 = read=3D4 dirtied=3D2 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 68.878 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130010.86..130010.87 rows=3D1 width=3D32) (actual = time=3D68.873..68.873 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130010.84..130010.86 rows=3D1 width=3D32) = (actual time=3D68.868..68.869 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130007.44 = rows=3D340 width=3D8) (actual time=3D68.846..68.846 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((sample =3D 1) AND (ind_vars[26] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.275..14.275 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 65.541 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D129681.69..129681.70 rows=3D1 width=3D32) (actual = time=3D65.535..65.535 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D129681.67..129681.69 rows=3D1 width=3D32) = (actual time=3D65.530..65.531 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..129678.27 = rows=3D340 width=3D8) (actual time=3D65.507..65.507 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.454..14.454 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:26 EET LOG: duration: 147.578 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130697.97..130697.98 rows=3D1 width=3D32) (actual = time=3D147.571..147.571 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4293.97..130024.20 = rows=3D67377 width=3D267) (actual time=3D16.725..103.089 rows=3D92229 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D15.470..15.470 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:26 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 493.864 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D142859.01..143169.74 rows=3D11299 width=3D36) = (actual time=3D493.861..493.861 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D1499 read=3D14 dirtied=3D13, = temp read=3D294 written=3D892 CTE cap2 -> WindowAgg (cost=3D135427.83..139080.28 rows=3D52836 = width=3D48) (actual time=3D222.309..390.349 rows=3D84582 loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 written=3D294 -> GroupAggregate (cost=3D135427.83..137363.11 rows=3D52836 = width=3D28) (actual time=3D222.271..289.879 rows=3D84582 loops=3D1) Group Key: (d_sample.ind_vars[26]) Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Sort (cost=3D135427.83..135596.27 rows=3D67377 = width=3D16) (actual time=3D220.159..238.125 rows=3D92229 loops=3D1) Sort Key: (d_sample.ind_vars[26]) Sort Method: external merge Disk: 2344kB Buffers: shared hit=3D9276, temp read=3D294 = written=3D294 -> Bitmap Heap Scan on d_sample = (cost=3D4293.97..130024.20 rows=3D67377 width=3D16) (actual = time=3D15.224..121.037 rows=3D92229 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND = (ind_vars[26] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 37505 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.041..14.041 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D3778.73..4089.45 = rows=3D11299 width=3D36) (actual time=3D491.072..491.840 rows=3D1476 = loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 written=3D892 -> HashAggregate (cost=3D3778.73..3891.72 rows=3D11299 = width=3D48) (actual time=3D491.065..491.359 rows=3D1476 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276, temp read=3D294 written=3D892 -> Append (cost=3D3270.28..3609.25 rows=3D11299 = width=3D48) (actual time=3D489.502..490.381 rows=3D1476 loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 = written=3D892 -> WindowAgg (cost=3D3270.28..3496.24 = rows=3D11298 width=3D48) (actual time=3D489.501..490.274 rows=3D1475 = loops=3D1) Buffers: shared hit=3D9276, temp read=3D294 = written=3D892 -> Sort (cost=3D3270.28..3298.52 = rows=3D11298 width=3D32) (actual time=3D489.494..489.625 rows=3D1475 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 164kB Buffers: shared hit=3D9276, temp = read=3D294 written=3D892 -> CTE Scan on cap2 = (cost=3D0.00..2509.71 rows=3D11298 width=3D32) (actual = time=3D223.890..489.000 rows=3D1475 loops=3D1) Filter: ((((sum_defaults / = '1887'::double precision) >=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '1887'::double precision) <=3D ((sum_observations)::double precision / = '92229'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 92229)) Rows Removed by Filter: 83107 Buffers: shared hit=3D9276, temp = read=3D294 written=3D892 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.007..0.007 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:27 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 1.451 ms plan: Query Text: SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1 Limit (cost=3D79.42..79.98 rows=3D1 width=3D76) (actual = time=3D1.449..1.449 rows=3D1 loops=3D1) Buffers: local hit=3D13 -> Result (cost=3D79.42..902.29 rows=3D1476 width=3D76) (actual = time=3D1.447..1.447 rows=3D1 loops=3D1) Buffers: local hit=3D13 -> Sort (cost=3D79.42..83.11 rows=3D1476 width=3D60) (actual = time=3D1.315..1.315 rows=3D1 loops=3D1) Sort Key: (('1'::double precision * = ((((cap.sum_defaults)::double precision - '0'::double precision) / = '1887'::double precision) - (((cap.sum_observations - 0))::double = precision / '92229'::double precision)))) DESC Sort Method: top-N heapsort Memory: 25kB Buffers: local hit=3D13 -> Seq Scan on cap (cost=3D0.00..72.04 rows=3D1476 = width=3D60) (actual time=3D0.018..1.002 rows=3D1475 loops=3D1) Filter: ((point > 0) AND (point <=3D 1475)) Rows Removed by Filter: 1 Buffers: local hit=3D13 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT point, min_value, max_value, next_value, sum_observations, sum_defaults,=0D sum_observations - p_l_sum_observations,=0D p_r_sum_observations - sum_observations, stat.binomial_test((sum_defaults - p_l_sum_defaults)::integer, = sum_observations - p_l_sum_observations, v_df), stat.binomial_test((p_r_sum_defaults - sum_defaults)::integer, = p_r_sum_observations - sum_observations, v_df), coalesce(p_dir, sign(y - x)) = = = FROM cap, LATERAL ( SELECT (sum_observations - p_l_sum_observations)::float / v_observations = AS x, CASE WHEN v_defaults =3D 0 THEN 0 ELSE (sum_defaults - p_l_sum_defaults) / v_defaults END AS y ) t WHERE point > p_l_point AND point <=3D p_r_point ORDER BY CASE WHEN p_dir IS NULL THEN ABS(y - x) ELSE p_dir * (y - x) END DESC LIMIT 1" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 32 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 1.437 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.437..1.437 rows=3D1 loops=3D1) Buffers: local hit=3D49 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 3.231 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3.229..3.229 rows=3D1 loops=3D1) Buffers: local hit=3D79 read=3D2 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, p_l_point, p_l_min_value, p_l_next_value, = p_l_sum_observations, p_l_sum_defaults, v_split_point, v_split_max_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 99 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 1.227 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.226..1.226 rows=3D1 loops=3D1) Buffers: local hit=3D47 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 3.033 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D3.032..3.032 rows=3D1 loops=3D1) Buffers: local hit=3D79 read=3D1 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( p_level + 1, v_split_point, v_split_min_value, v_split_next_value, = v_split_sum_observations, v_split_sum_defaults, p_r_point, p_r_max_value, p_r_next_value, p_r_sum_observations, = p_r_sum_defaults, v_dir, p_max_p_value, p_min_population, p_max_level, = p_logit_in_bounds, p_bins, p_bounds, p_nodes)" PL/pgSQL function pd.p_discretize_monotone(integer,integer,double = precision,double precision,integer,double precision,integer,double = precision,double precision,integer,double precision,double = precision,double = precision,integer,integer,boolean,pd.crit_bin[],pd.crit_bound[],pd.crit_n= ode[]) line 108 at SQL statement SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 9.197 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D9.195..9.195 rows=3D1 loops=3D1) Buffers: shared hit=3D15, local hit=3D174 read=3D6 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 834.540 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D834.538..834.538 rows=3D1 loops=3D1) Buffers: shared hit=3D37284 read=3D3 dirtied=3D4, local hit=3D1712 = read=3D21 dirtied=3D13, temp read=3D294 written=3D893 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 58.298 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D130126.45..130126.46 rows=3D1 width=3D16) (actual = time=3D58.290..58.290 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4282.80..130013.03 = rows=3D22685 width=3D8) (actual time=3D15.765..57.188 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D '0.00172989178304991'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.581..14.581 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 58.673 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130337.71..130337.72 rows=3D1 width=3D32) (actual = time=3D58.668..58.669 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130337.69..130337.71 rows=3D1 width=3D32) = (actual time=3D58.664..58.664 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130336.56 = rows=3D113 width=3D8) (actual time=3D58.641..58.641 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[8] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.064..14.064 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 55.369 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130008.53..130008.54 rows=3D1 width=3D32) (actual = time=3D55.363..55.363 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130008.52..130008.53 rows=3D1 width=3D32) = (actual time=3D55.358..55.359 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130007.39 = rows=3D113 width=3D8) (actual time=3D55.336..55.336 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.019..14.019 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 80.008 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130566.74..130566.75 rows=3D1 width=3D32) (actual = time=3D80.001..80.001 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4282.74..130342.15 = rows=3D22459 width=3D267) (actual time=3D15.555..75.780 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D13.966..13.966 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 78.916 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D134639.66..134761.29 rows=3D4423 width=3D36) = (actual time=3D78.913..78.913 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D7 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D132673.71..133190.66 rows=3D20678 = width=3D48) (actual time=3D77.561..77.886 rows=3D332 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D132673.71..132725.40 rows=3D20678 = width=3D28) (actual time=3D77.541..77.567 rows=3D332 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 50kB Buffers: shared hit=3D9276 -> Subquery Scan on cap1 (cost=3D130622.89..131191.53 = rows=3D20678 width=3D28) (actual time=3D77.233..77.406 rows=3D332 = loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D130622.89..130984.75 = rows=3D20678 width=3D28) (actual time=3D77.232..77.372 rows=3D332 = loops=3D1) Group Key: d_sample.ind_vars[8] Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4282.74..130342.15 rows=3D22459 width=3D16) (actual = time=3D15.131..74.124 rows=3D9896 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D13.943..13.943 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D1449.00..1570.63 rows=3D4423 = width=3D36) (actual time=3D78.219..78.239 rows=3D7 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D1449.00..1493.23 rows=3D4423 = width=3D48) (actual time=3D78.215..78.230 rows=3D7 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D1249.97..1382.66 rows=3D4423 = width=3D48) (actual time=3D78.191..78.202 rows=3D7 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D1249.97..1338.41 rows=3D4422 = width=3D48) (actual time=3D78.190..78.195 rows=3D6 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D1249.97..1261.02 = rows=3D4422 width=3D32) (actual time=3D78.186..78.187 rows=3D6 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..982.21 rows=3D4422 width=3D32) (actual = time=3D77.665..78.177 rows=3D6 loops=3D1) Filter: ((((sum_defaults / = '4'::double precision) >=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope < slope)) OR (((sum_defaults = / '4'::double precision) <=3D ((sum_observations)::double precision / = '9896'::double precision)) AND (next_slope > slope)) OR = (sum_observations =3D 9896)) Rows Removed by Filter: 326 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.005 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:27 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 298.060 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D298.059..298.059 rows=3D1 loops=3D1) Buffers: shared hit=3D37252, local hit=3D11 read=3D2 dirtied=3D1 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 57.720 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130337.71..130337.72 rows=3D1 width=3D32) (actual = time=3D57.715..57.716 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130337.69..130337.71 rows=3D1 width=3D32) = (actual time=3D57.710..57.710 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130336.56 = rows=3D113 width=3D8) (actual time=3D57.689..57.689 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[22] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D13.949..13.949 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 64.561 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130008.53..130008.54 rows=3D1 width=3D32) (actual = time=3D64.555..64.555 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130008.52..130008.53 rows=3D1 width=3D32) = (actual time=3D64.550..64.550 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130007.39 = rows=3D113 width=3D8) (actual time=3D15.726..63.536 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.562..14.562 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 55.222 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130566.74..130566.75 rows=3D1 width=3D32) (actual = time=3D55.215..55.215 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4282.74..130342.15 = rows=3D22459 width=3D267) (actual time=3D24.156..54.909 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D13.899..13.899 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 61.369 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D135509.24..135630.87 rows=3D4423 width=3D36) = (actual time=3D61.365..61.365 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D4 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D133439.90..133956.85 rows=3D20678 = width=3D48) (actual time=3D59.368..60.012 rows=3D586 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D133439.90..133491.60 rows=3D20678 = width=3D28) (actual time=3D59.343..59.395 rows=3D586 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 70kB Buffers: shared hit=3D9276 -> Subquery Scan on cap1 (cost=3D131337.38..131957.72 = rows=3D20678 width=3D28) (actual time=3D58.755..59.095 rows=3D586 = loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D131337.38..131750.94 = rows=3D20678 width=3D28) (actual time=3D58.753..59.042 rows=3D586 = loops=3D1) Group Key: d_sample.ind_vars[$1] Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4282.74..131056.65 rows=3D22459 width=3D16) (actual = time=3D26.400..58.285 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[$1] IS NOT NULL) = AND (sample =3D 1) AND (ind_vars[$1] <> 'NaN'::double precision)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.080..15.080 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D1552.39..1674.02 rows=3D4423 = width=3D36) (actual time=3D60.675..60.692 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D1552.39..1596.62 rows=3D4423 = width=3D48) (actual time=3D60.670..60.683 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D1353.36..1486.05 rows=3D4423 = width=3D48) (actual time=3D60.650..60.658 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D1353.36..1441.80 rows=3D4422 = width=3D48) (actual time=3D60.649..60.652 rows=3D3 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D1353.36..1364.41 = rows=3D4422 width=3D32) (actual time=3D60.644..60.645 rows=3D3 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..1085.60 rows=3D4422 width=3D32) (actual = time=3D59.650..60.636 rows=3D3 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 583 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.005 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:27 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 254.538 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D254.536..254.536 rows=3D1 loops=3D1) Buffers: shared hit=3D37256 read=3D1 dirtied=3D2, local hit=3D8 = read=3D2 dirtied=3D1 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 61.707 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130337.71..130337.72 rows=3D1 width=3D32) (actual = time=3D61.702..61.702 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130337.69..130337.71 rows=3D1 width=3D32) = (actual time=3D61.697..61.697 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130336.56 = rows=3D113 width=3D8) (actual time=3D61.676..61.676 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[26] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.962..15.962 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 64.419 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130008.53..130008.54 rows=3D1 width=3D32) (actual = time=3D64.413..64.413 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130008.52..130008.53 rows=3D1 width=3D32) = (actual time=3D64.408..64.408 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130007.39 = rows=3D113 width=3D8) (actual time=3D64.386..64.386 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.171..14.171 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:27 EET LOG: duration: 90.250 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130566.74..130566.75 rows=3D1 width=3D32) (actual = time=3D90.240..90.240 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4282.74..130342.15 = rows=3D22459 width=3D267) (actual time=3D16.725..84.912 rows=3D9896 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[26] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D15.404..15.404 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:27 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 103.273 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D135509.24..135630.87 rows=3D4423 width=3D36) = (actual time=3D103.269..103.269 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D8 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D133439.90..133956.85 rows=3D20678 = width=3D48) (actual time=3D82.644..93.261 rows=3D9875 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D133439.90..133491.60 rows=3D20678 = width=3D28) (actual time=3D82.620..84.284 rows=3D9875 loops=3D1) Sort Key: cap1.var_value Sort Method: quicksort Memory: 1156kB Buffers: shared hit=3D9276 -> Subquery Scan on cap1 (cost=3D131337.38..131957.72 = rows=3D20678 width=3D28) (actual time=3D71.100..77.319 rows=3D9875 = loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D131337.38..131750.94 = rows=3D20678 width=3D28) (actual time=3D71.099..76.249 rows=3D9875 = loops=3D1) Group Key: d_sample.ind_vars[$1] Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4282.74..131056.65 rows=3D22459 width=3D16) (actual = time=3D15.512..65.912 rows=3D9896 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[$1] IS NOT NULL) = AND (sample =3D 1) AND (ind_vars[$1] <> 'NaN'::double precision)) Rows Removed by Filter: 119838 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.262..14.262 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) = AND (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D1552.39..1674.02 rows=3D4423 = width=3D36) (actual time=3D102.570..102.592 rows=3D8 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D1552.39..1596.62 rows=3D4423 = width=3D48) (actual time=3D102.564..102.581 rows=3D8 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D1353.36..1486.05 rows=3D4423 = width=3D48) (actual time=3D102.538..102.549 rows=3D8 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D1353.36..1441.80 rows=3D4422 = width=3D48) (actual time=3D102.537..102.542 rows=3D7 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D1353.36..1364.41 = rows=3D4422 width=3D32) (actual time=3D102.532..102.533 rows=3D7 = loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..1085.60 rows=3D4422 width=3D32) (actual = time=3D83.723..102.520 rows=3D7 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 9868 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:28 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 339.966 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D339.964..339.964 rows=3D1 loops=3D1) Buffers: shared hit=3D37266 dirtied=3D1, local hit=3D12 read=3D2 = dirtied=3D1 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 59.170 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D130376.23..130376.24 rows=3D1 width=3D16) (actual = time=3D59.162..59.162 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4279.02..130338.42 = rows=3D7562 width=3D8) (actual time=3D26.269..59.052 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D '0.00172989178304991'::double = precision) AND (ind_vars[22] <=3D 'Infinity'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.709..14.709 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 58.734 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130666.12..130666.13 rows=3D1 width=3D32) (actual = time=3D58.729..58.729 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130666.10..130666.12 rows=3D1 width=3D32) = (actual time=3D58.724..58.724 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.14..130665.72 = rows=3D38 width=3D8) (actual time=3D58.703..58.703 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1) AND (ind_vars[8] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.457..14.457 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 55.849 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130336.94..130336.95 rows=3D1 width=3D32) (actual = time=3D55.843..55.843 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.92..130336.94 rows=3D1 width=3D32) = (actual time=3D55.838..55.838 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.14..130336.54 = rows=3D38 width=3D8) (actual time=3D55.815..55.815 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.119..14.119 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 71.829 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130742.44..130742.45 rows=3D1 width=3D32) (actual = time=3D71.821..71.821 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4279.00..130667.58 = rows=3D7486 width=3D267) (actual time=3D29.624..71.536 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[8] <> 'NaN'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.091..14.091 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 59.467 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D132855.83..132898.67 rows=3D1558 width=3D36) = (actual time=3D59.463..59.463 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D4 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131826.37..132320.91 rows=3D7281 width=3D48) = (actual time=3D58.396..58.676 rows=3D50 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D131826.37..132084.28 rows=3D7281 = width=3D28) (actual time=3D58.362..58.582 rows=3D50 loops=3D1) Group Key: (d_sample.ind_vars[$1]) Buffers: shared hit=3D9276 -> Sort (cost=3D131826.37..131845.08 rows=3D7486 = width=3D16) (actual time=3D58.344..58.422 rows=3D632 loops=3D1) Sort Key: (d_sample.ind_vars[$1]) Sort Method: quicksort Memory: 54kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4279.00..131344.64 rows=3D7486 width=3D16) (actual = time=3D24.979..58.062 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[$1] IS NOT NULL) AND (sample = =3D 1) AND (ind_vars[$1] <> 'NaN'::double precision)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.231..14.231 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D534.92..577.76 rows=3D1558 = width=3D36) (actual time=3D58.788..58.795 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D534.92..550.50 rows=3D1558 = width=3D48) (actual time=3D58.781..58.787 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D464.81..511.55 rows=3D1558 = width=3D48) (actual time=3D58.761..58.770 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D464.81..495.95 rows=3D1557 = width=3D48) (actual time=3D58.760..58.763 rows=3D3 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D464.81..468.70 rows=3D1557 = width=3D32) (actual time=3D58.756..58.757 rows=3D3 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..382.25 rows=3D1557 width=3D32) (actual = time=3D58.612..58.748 rows=3D3 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 47 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.005..0.005 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:28 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 1.216 ms plan: Query Text: SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes) Function Scan on p_discretize_monotone (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D1.215..1.215 rows=3D1 loops=3D1) Buffers: shared hit=3D28, local hit=3D1 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT * FROM pd.p_discretize_monotone( 0, 0, '-Infinity'::float, v_min_value, 0, 0, v_cap_points - 1, v_max_value, 'Infinity'::float, v_observations, = v_defaults, p_dir, p_max_p_value, p_min_population, p_max_level, false, bins, = bounds, nodes)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 298 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 262.050 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D262.048..262.048 rows=3D1 loops=3D1) Buffers: shared hit=3D37285, local hit=3D8 read=3D2 dirtied=3D1 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 56.152 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130666.12..130666.13 rows=3D1 width=3D32) (actual = time=3D56.147..56.147 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130666.10..130666.12 rows=3D1 width=3D32) = (actual time=3D56.142..56.142 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.14..130665.72 = rows=3D38 width=3D8) (actual time=3D56.121..56.121 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1) AND (ind_vars[26] =3D = 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D13.963..13.963 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 66.584 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130336.94..130336.95 rows=3D1 width=3D32) (actual = time=3D66.578..66.578 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.92..130336.94 rows=3D1 width=3D32) = (actual time=3D66.573..66.573 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.14..130336.54 = rows=3D38 width=3D8) (actual time=3D66.550..66.550 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.929..15.929 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 83.847 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130742.44..130742.45 rows=3D1 width=3D32) (actual = time=3D83.840..83.840 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4279.00..130667.58 = rows=3D7486 width=3D267) (actual time=3D31.971..83.545 rows=3D632 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[26] IS NOT NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[26] <> 'NaN'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D15.198..15.198 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 62.936 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D132855.83..132898.67 rows=3D1558 width=3D36) = (actual time=3D62.933..62.933 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D4 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131826.37..132320.91 rows=3D7281 width=3D48) = (actual time=3D60.288..61.502 rows=3D631 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D131826.37..132084.28 rows=3D7281 = width=3D28) (actual time=3D60.255..60.719 rows=3D631 loops=3D1) Group Key: (d_sample.ind_vars[$1]) Buffers: shared hit=3D9276 -> Sort (cost=3D131826.37..131845.08 rows=3D7486 = width=3D16) (actual time=3D60.237..60.335 rows=3D632 loops=3D1) Sort Key: (d_sample.ind_vars[$1]) Sort Method: quicksort Memory: 54kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4279.00..131344.64 rows=3D7486 width=3D16) (actual = time=3D26.434..59.830 rows=3D632 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (ind_vars[22] <=3D = 'Infinity'::double precision) AND (ind_vars[$1] IS NOT NULL) AND (sample = =3D 1) AND (ind_vars[$1] <> 'NaN'::double precision)) Rows Removed by Filter: 129102 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.223..14.223 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D534.92..577.76 rows=3D1558 = width=3D36) (actual time=3D62.252..62.260 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D534.92..550.50 rows=3D1558 = width=3D48) (actual time=3D62.246..62.251 rows=3D4 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D464.81..511.55 rows=3D1558 = width=3D48) (actual time=3D62.223..62.233 rows=3D4 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D464.81..495.95 rows=3D1557 = width=3D48) (actual time=3D62.223..62.226 rows=3D3 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D464.81..468.70 rows=3D1557 = width=3D32) (actual time=3D62.218..62.219 rows=3D3 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..382.25 rows=3D1557 width=3D32) (actual = time=3D60.493..62.210 rows=3D3 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 628 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:28 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 284.616 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D284.615..284.615 rows=3D1 loops=3D1) Buffers: shared hit=3D37279 dirtied=3D2, local hit=3D8 read=3D2 = dirtied=3D1 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 620.097 ms plan: Query Text: SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D ) Result (cost=3D0.00..0.27 rows=3D1 width=3D32) (actual = time=3D620.093..620.094 rows=3D1 loops=3D1) Buffers: shared hit=3D83979 dirtied=3D2, local hit=3D16 read=3D4 = dirtied=3D2 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT = dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 65.569 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D130007.95..130007.96 rows=3D1 width=3D16) (actual = time=3D65.561..65.561 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130007.39 = rows=3D113 width=3D8) (actual time=3D15.313..64.528 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.080..14.080 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 63.789 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130336.56..130336.57 rows=3D1 width=3D32) (actual = time=3D63.783..63.783 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.54..130336.56 rows=3D1 width=3D32) = (actual time=3D63.778..63.778 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130336.53 = rows=3D1 width=3D8) (actual time=3D63.755..63.755 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[8] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D13.944..13.944 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 64.439 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130007.39..130007.40 rows=3D1 width=3D32) (actual = time=3D64.433..64.433 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130007.37..130007.39 rows=3D1 width=3D32) = (actual time=3D64.428..64.428 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130007.36 = rows=3D1 width=3D8) (actual time=3D64.404..64.404 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[8] IS = NULL) AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.781..14.781 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:28 EET LOG: duration: 82.668 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130337.68..130337.69 rows=3D1 width=3D32) (actual = time=3D82.661..82.661 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130336.56 = rows=3D112 width=3D267) (actual time=3D16.130..78.790 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[8] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[8] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.875..14.875 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:28 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 77.919 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D131014.12..131014.80 rows=3D25 width=3D36) = (actual time=3D77.915..77.915 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D6 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D130999.00..131006.56 rows=3D112 width=3D48) = (actual time=3D73.212..76.871 rows=3D329 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D130999.00..131002.92 rows=3D112 = width=3D28) (actual time=3D73.178..76.375 rows=3D329 loops=3D1) Group Key: (d_sample.ind_vars[$1]) Buffers: shared hit=3D9276 -> Sort (cost=3D130999.00..130999.28 rows=3D112 = width=3D16) (actual time=3D73.161..74.401 rows=3D9264 loops=3D1) Sort Key: (d_sample.ind_vars[$1]) Sort Method: quicksort Memory: 819kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4277.16..130995.19 rows=3D112 width=3D16) (actual = time=3D15.815..70.538 rows=3D9264 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND = (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[$1] IS NOT NULL) AND (sample =3D 1) AND (ind_vars[$1] <> = 'NaN'::double precision)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.518..14.518 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D7.55..8.24 rows=3D25 = width=3D36) (actual time=3D77.336..77.343 rows=3D6 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D7.55..7.80 rows=3D25 width=3D48) = (actual time=3D77.332..77.334 rows=3D6 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D6.43..7.18 rows=3D25 width=3D48) = (actual time=3D77.308..77.321 rows=3D6 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D6.43..6.91 rows=3D24 = width=3D48) (actual time=3D77.307..77.311 rows=3D5 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D6.43..6.49 rows=3D24 = width=3D32) (actual time=3D77.301..77.301 rows=3D5 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..5.88 rows=3D24 width=3D32) (actual time=3D73.435..77.291 = rows=3D5 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 324 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.007..0.008 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:29 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 306.361 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D306.358..306.358 rows=3D1 loops=3D1) Buffers: shared hit=3D37271, local hit=3D10 read=3D2 dirtied=3D1 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 68.175 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130336.56..130336.57 rows=3D1 width=3D32) (actual = time=3D68.169..68.170 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.54..130336.56 rows=3D1 width=3D32) = (actual time=3D68.165..68.165 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130336.53 = rows=3D1 width=3D8) (actual time=3D68.144..68.144 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] <=3D = '0.00172989178304991'::double precision) AND (sample =3D 1) AND = (ind_vars[26] =3D 'NaN'::double precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.360..15.360 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 72.028 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130007.39..130007.40 rows=3D1 width=3D32) (actual = time=3D72.021..72.022 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130007.37..130007.39 rows=3D1 width=3D32) = (actual time=3D72.017..72.018 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130007.36 = rows=3D1 width=3D8) (actual time=3D71.994..71.994 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[26] IS = NULL) AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.123..14.123 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 93.689 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130337.68..130337.69 rows=3D1 width=3D32) (actual = time=3D93.683..93.683 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.16..130336.56 = rows=3D112 width=3D267) (actual time=3D15.290..87.103 rows=3D9264 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[26] IS NOT NULL) = AND (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[26] <> 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.093..14.093 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 108.321 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D131014.12..131014.80 rows=3D25 width=3D36) = (actual time=3D108.317..108.317 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D7 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D130999.00..131006.56 rows=3D112 width=3D48) = (actual time=3D77.355..96.988 rows=3D9246 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D130999.00..131002.92 rows=3D112 = width=3D28) (actual time=3D77.327..85.007 rows=3D9246 loops=3D1) Group Key: (d_sample.ind_vars[$1]) Buffers: shared hit=3D9276 -> Sort (cost=3D130999.00..130999.28 rows=3D112 = width=3D16) (actual time=3D77.312..79.215 rows=3D9264 loops=3D1) Sort Key: (d_sample.ind_vars[$1]) Sort Method: quicksort Memory: 819kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4277.16..130995.19 rows=3D112 width=3D16) (actual = time=3D15.387..72.153 rows=3D9264 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND = (ind_vars[1] <=3D '0.00172989178304991'::double precision) AND = (ind_vars[$1] IS NOT NULL) AND (sample =3D 1) AND (ind_vars[$1] <> = 'NaN'::double precision)) Rows Removed by Filter: 120470 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.194..14.194 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D7.55..8.24 rows=3D25 = width=3D36) (actual time=3D107.610..107.616 rows=3D7 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D7.55..7.80 rows=3D25 width=3D48) = (actual time=3D107.605..107.608 rows=3D7 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D6.43..7.18 rows=3D25 width=3D48) = (actual time=3D107.575..107.593 rows=3D7 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D6.43..6.91 rows=3D24 = width=3D48) (actual time=3D107.575..107.581 rows=3D6 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D6.43..6.49 rows=3D24 = width=3D32) (actual time=3D107.568..107.568 rows=3D6 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 25kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..5.88 rows=3D24 width=3D32) (actual time=3D81.297..107.549 = rows=3D6 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 9240 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.010..0.010 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:29 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 357.709 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D357.707..357.707 rows=3D1 loops=3D1) Buffers: shared hit=3D37260 dirtied=3D1, local hit=3D11 read=3D2 = dirtied=3D1 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement SQL statement "SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 743.356 ms plan: Query Text: SELECT dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D ) Result (cost=3D0.00..0.27 rows=3D1 width=3D32) (actual = time=3D743.352..743.353 rows=3D1 loops=3D1) Buffers: shared hit=3D83948 dirtied=3D2, local hit=3D21 read=3D4 = dirtied=3D2 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT = dt.p_create_node(=0D p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest,=0D CASE WHEN p_one_node_per_crit THEN=0D array_remove(p_criteria, v_best_ord)=0D ELSE=0D p_criteria=0D END,=0D p_one_node_per_crit,=0D p_min_population,=0D p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'),=0D v_node_view, p_tree_nodes=0D )" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 69.157 ms plan: Query Text: SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample Aggregate (cost=3D130338.32..130338.33 rows=3D1 width=3D16) (actual = time=3D69.150..69.150 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130336.62 = rows=3D340 width=3D8) (actual time=3D15.290..67.982 rows=3D10703 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.052..14.052 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT=0D count(*),=0D sum(dep_var)=0D FROM=0D sample" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 42 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 68.772 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130665.75..130665.76 rows=3D1 width=3D32) (actual = time=3D68.767..68.767 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130665.73..130665.75 rows=3D1 width=3D32) = (actual time=3D68.761..68.761 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130665.71 = rows=3D2 width=3D8) (actual time=3D68.741..68.741 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1) AND (ind_vars[8] =3D 'NaN'::double = precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.169..14.169 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 56.074 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130336.57..130336.58 rows=3D1 width=3D32) (actual = time=3D56.069..56.069 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.55..130336.57 rows=3D1 width=3D32) = (actual time=3D56.064..56.065 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130336.53 = rows=3D2 width=3D8) (actual time=3D56.040..56.040 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.058..14.058 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 92.514 ms plan: Query Text: SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float Aggregate (cost=3D130669.16..130669.17 rows=3D1 width=3D32) (actual = time=3D92.506..92.506 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.21..130665.79 = rows=3D337 width=3D267) (actual time=3D15.890..88.003 rows=3D10703 = loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[8] IS NOT NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[8] <> = 'NaN'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk (cost=3D0.00..4277.13 = rows=3D131670 width=3D0) (actual time=3D14.585..14.585 rows=3D129734 = loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT count(*), sum(dep_var), min(ind_vars[p_ord]), max(ind_vars[p_ord]) = FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 81 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 83.592 ms plan: Query Text: WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0) Insert on cap (cost=3D131385.08..131387.08 rows=3D73 width=3D36) = (actual time=3D83.589..83.589 rows=3D0 loops=3D1) Buffers: shared hit=3D9276, local hit=3D15 read=3D1 dirtied=3D1 CTE cap2 -> WindowAgg (cost=3D131339.13..131361.88 rows=3D337 width=3D48) = (actual time=3D78.655..82.452 rows=3D381 loops=3D1) Buffers: shared hit=3D9276 -> GroupAggregate (cost=3D131339.13..131350.93 rows=3D337 = width=3D28) (actual time=3D78.626..81.978 rows=3D381 loops=3D1) Group Key: (d_sample.ind_vars[$1]) Buffers: shared hit=3D9276 -> Sort (cost=3D131339.13..131339.98 rows=3D337 = width=3D16) (actual time=3D78.609..79.846 rows=3D10703 loops=3D1) Sort Key: (d_sample.ind_vars[$1]) Sort Method: quicksort Memory: 886kB Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample = (cost=3D4277.21..131324.98 rows=3D337 width=3D16) (actual = time=3D15.549..75.854 rows=3D10703 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Filter: ((ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (ind_vars[$1] IS NOT NULL) = AND (sample =3D 1) AND (ind_vars[$1] <> 'NaN'::double precision)) Rows Removed by Filter: 119031 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D14.271..14.271 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND = (project_id =3D 13)) Buffers: shared hit=3D1588 -> Subquery Scan on "*SELECT*" (cost=3D23.20..25.20 rows=3D73 = width=3D36) (actual time=3D82.908..82.918 rows=3D15 loops=3D1) Buffers: shared hit=3D9276 -> HashAggregate (cost=3D23.20..23.93 rows=3D73 width=3D48) = (actual time=3D82.902..82.906 rows=3D15 loops=3D1) Group Key: (row_number() OVER (?)), (lag(cap2.next_value) = OVER (?)), cap2.var_value, cap2.next_value, cap2.sum_observations, = cap2.sum_defaults Buffers: shared hit=3D9276 -> Append (cost=3D19.91..22.10 rows=3D73 width=3D48) = (actual time=3D82.870..82.887 rows=3D15 loops=3D1) Buffers: shared hit=3D9276 -> WindowAgg (cost=3D19.91..21.35 rows=3D72 = width=3D48) (actual time=3D82.870..82.878 rows=3D14 loops=3D1) Buffers: shared hit=3D9276 -> Sort (cost=3D19.91..20.09 rows=3D72 = width=3D32) (actual time=3D82.865..82.866 rows=3D14 loops=3D1) Sort Key: cap2.var_value Sort Method: quicksort Memory: 26kB Buffers: shared hit=3D9276 -> CTE Scan on cap2 = (cost=3D0.00..17.69 rows=3D72 width=3D32) (actual time=3D78.871..82.856 = rows=3D14 loops=3D1) Filter: ((((sum_defaults / $17) = >=3D ((sum_observations)::double precision / ($16)::double precision)) = AND (next_slope < slope)) OR (((sum_defaults / $17) <=3D = ((sum_observations)::double precision / ($16)::double precision)) AND = (next_slope > slope)) OR (sum_observations =3D $16)) Rows Removed by Filter: 367 Buffers: shared hit=3D9276 -> Subquery Scan on "*SELECT* 2" = (cost=3D0.00..0.03 rows=3D1 width=3D48) (actual time=3D0.006..0.006 = rows=3D1 loops=3D1) -> Result (cost=3D0.00..0.01 rows=3D1 = width=3D36) (actual time=3D0.002..0.002 rows=3D1 loops=3D1) 2018-02-09 11:34:29 EET CONTEXT: SQL statement "WITH cap2 AS (=20 SELECT var_value, slope, lead(var_value) OVER w AS next_value, lead(slope) OVER w AS next_slope, sum(observations) OVER w AS sum_observations, sum(defaults_num) OVER w AS sum_defaults FROM ( SELECT -- Group identical values ind_vars[p_ord] AS var_value, count(*)::integer AS observations, sum(dep_var) AS defaults_num, sum(dep_var) / count(*) AS slope FROM sample WHERE ind_vars[p_ord] IS NOT NULL=0D AND ind_vars[p_ord] <> 'NaN'::float GROUP BY ind_vars[p_ord] ) cap1 WINDOW w AS (ORDER BY var_value) ) INSERT INTO -- Minimize the points of CAP cap SELECT row_number() OVER w, lag(next_value) OVER w, var_value, next_value, sum_observations, sum_defaults FROM cap2, LATERAL ( SELECT sum_observations::float / v_observations AS x, sum_defaults / v_defaults AS y ) t WHERE (y >=3D x AND next_slope < slope) OR (y <=3D x AND next_slope > slope) OR (sum_observations =3D v_observations) WINDOW w AS (ORDER BY var_value) UNION VALUES(0, '-Infinity'::float, '-Infinity'::float, '-Infinity'::float, = 0, 0)" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 125 at = SQL statement SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 316.811 ms plan: Query Text: SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df) Function Scan on p_bin_continuous (cost=3D0.25..0.26 rows=3D1 = width=3D96) (actual time=3D316.809..316.809 rows=3D1 loops=3D1) Buffers: shared hit=3D37300, local hit=3D19 read=3D2 dirtied=3D1 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 71.798 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D ) Result (cost=3D130665.75..130665.76 rows=3D1 width=3D32) (actual = time=3D71.793..71.793 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130665.73..130665.75 rows=3D1 width=3D32) = (actual time=3D71.788..71.788 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130665.71 = rows=3D2 width=3D8) (actual time=3D71.767..71.767 rows=3D0 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[1] > '0.00172989178304991'::double = precision) AND (ind_vars[1] <=3D '0.00363416191114579'::double = precision) AND (sample =3D 1) AND (ind_vars[22] =3D 'NaN'::double = precision)) Rows Removed by Filter: 129734 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D15.393..15.393 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D 'NaN'::float,=0D 'NaN'::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] =3D 'NaN'::float=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 40 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment 2018-02-09 11:34:29 EET LOG: duration: 74.616 ms plan: Query Text: SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D ) Result (cost=3D130336.57..130336.58 rows=3D1 width=3D32) (actual = time=3D74.611..74.611 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 InitPlan 1 (returns $0) -> Aggregate (cost=3D130336.55..130336.57 rows=3D1 width=3D32) = (actual time=3D74.605..74.605 rows=3D1 loops=3D1) Buffers: shared hit=3D9276 -> Bitmap Heap Scan on d_sample (cost=3D4277.13..130336.53 = rows=3D2 width=3D8) (actual time=3D15.158..73.547 rows=3D9168 loops=3D1) Recheck Cond: ((unit_id =3D 1) AND (project_id =3D 13)) Filter: ((ind_vars[22] IS NULL) AND (ind_vars[1] > = '0.00172989178304991'::double precision) AND (ind_vars[1] <=3D = '0.00363416191114579'::double precision) AND (sample =3D 1)) Rows Removed by Filter: 120566 Heap Blocks: exact=3D7688 Buffers: shared hit=3D9276 -> Bitmap Index Scan on d_sample_pk = (cost=3D0.00..4277.13 rows=3D131670 width=3D0) (actual = time=3D13.951..13.951 rows=3D129734 loops=3D1) Index Cond: ((unit_id =3D 1) AND (project_id =3D = 13)) Buffers: shared hit=3D1588 2018-02-09 11:34:29 EET CONTEXT: SQL statement "SELECT (=0D SELECT =0D (=0D NULL::float,=0D NULL::float,=0D count(*)::integer,=0D coalesce(sum(dep_var), 0),=0D sum(dep_var) / count(*)=0D )::pd.crit_bin=0D FROM=0D sample=0D WHERE=0D ind_vars[p_ord] IS NULL=0D )" PL/pgSQL function = dt.p_bin_continuous(smallint,integer,integer,integer,double = precision,integer,boolean,double precision,double precision) line 55 at = assignment SQL statement "SELECT * FROM=0D dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population,=0D r.max_p_value, r.max_level, r.monotone, r.dir, v_df)" PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 85 at SQL statement PL/pgSQL function = dt.p_create_node(smallint,integer,smallint,integer,boolean,smallint[],boo= lean,integer,integer,double precision,smallint,double = precision,text,text,dt.tree_node[]) line 153 at assignment PL/pgSQL function = dt.c_create_tree(smallint,integer,smallint,smallint,smallint[],boolean,sm= allint[],boolean,integer,integer,double precision) line 17 at assignment ------=_NextPart_000_0476_01D3A1AD.CEC18700 Content-Type: text/plain; name="sql.sql" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="sql.sql" CREATE TABLE pd.d_sample ( unit_id smallint NOT NULL, project_id integer NOT NULL, subject_id text NOT NULL, ref_date text NOT NULL, dep_var double precision, ind_vars double precision[], grad_vars character varying[], trn_vars double precision[], sample smallint, score double precision, tree_bag bit varying, scores double precision[], CONSTRAINT d_sample_pk PRIMARY KEY (unit_id, project_id, subject_id, = ref_date) ); CREATE OR REPLACE FUNCTION dt.c_create_tree( p_unit_id smallint, p_project_id integer, p_permutation_id smallint, p_tree_ord smallint, p_samples smallint[], p_in_forest boolean, p_criteria smallint[], p_one_node_per_crit boolean, p_min_population integer, p_max_level integer, p_min_ar double precision) RETURNS void AS $BODY$ DECLARE v_tree_nodes dt.tree_node[]; BEGIN -- Grow the tree v_tree_nodes :=3D dt.p_create_node( p_unit_id, p_project_id, p_samples[1], p_tree_ord, p_in_forest, p_criteria, p_one_node_per_crit, p_min_population, p_max_level, p_min_ar, NULL, NULL, NULL, NULL, NULL ); =09 -- Store it in the table INSERT INTO pd.d_tree ( unit_id, project_id, permutation_id, tree_ord, ind_var_ids, nodes ) VALUES( p_unit_id, p_project_id, p_permutation_id, p_tree_ord, p_criteria, v_tree_nodes ) ON CONFLICT ON CONSTRAINT d_tree_pk DO UPDATE SET ind_var_ids =3D p_criteria, nodes =3D v_tree_nodes; -- Calculate AR of training sample PERFORM dt.p_evaluate_tree( p_unit_id, p_project_id, p_permutation_id, p_tree_ord, p_samples, p_in_forest, v_tree_nodes ); END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100; =20 CREATE OR REPLACE FUNCTION dt.p_create_node( IN p_unit_id smallint, IN p_project_id integer, IN p_sample smallint, IN p_tree_ord integer, IN p_in_forest boolean, IN p_criteria smallint[], IN p_one_node_per_crit boolean, IN p_min_population integer, IN p_max_level integer, IN p_min_ar double precision, IN p_crit_ord smallint, IN p_bound double precision, IN p_id text, IN p_view text, INOUT p_tree_nodes dt.tree_node[]) RETURNS dt.tree_node[] AS $BODY$ DECLARE r record; v_id text; v_view text; v_node_view text; v_bins pd.crit_bin[]; v_nodes pd.crit_node[]; v_bounds pd.crit_bound[]; v_ar float; v_best_ord smallint; v_best_ar float :=3D -1; v_best_bounds pd.crit_bound[]; v_best_cont boolean; v_bound pd.crit_bound; v_node dt.tree_node; v_df float; v_obs integer; v_def float; BEGIN -- If new tree initialize the text of the view IF p_view IS NULL THEN v_view :=3D=20 'CREATE OR REPLACE TEMP VIEW sample AS SELECT ind_vars,dep_var FROM = pd.d_sample ' || 'WHERE unit_id=3D' || p_unit_id || ' AND project_id=3D' || = p_project_id || ' AND sample =3D' || p_sample; IF p_in_forest THEN -- In case a tree of a random forest v_view :=3D v_view || ' AND get_bit(tree_bag,' || (p_tree_ord - 1) || = ')=3D1'; END IF; v_id :=3D '_'; p_tree_nodes :=3D ARRAY[]::dt.tree_node[]; ELSE v_view :=3D p_view; v_id :=3D p_id; END IF; -- Create the view EXECUTE v_view; -- Get number of observations and defaults of the view SELECT count(*), sum(dep_var) INTO v_obs, v_def FROM sample; -- Build a node v_node :=3D (v_id, p_bound, v_obs, v_def, NULL, NULL, = NULL)::dt.tree_node; -- Check if max level is reached or if no defaults exist IF (char_length(v_id) - 1) / 2 >=3D p_max_level OR v_def <=3D 0.5 THEN p_tree_nodes :=3D p_tree_nodes || v_node; RETURN; END IF; v_df :=3D v_def / v_obs; =09 -- Check for the best criterion to split FOR r IN SELECT ord, (discrete_values IS NULL OR monotone) AS continuous,=20 monotone, dir, min_ar, nan_behavior, null_behavior, max_p_value, max_level FROM pd.d_criterion WHERE unit_id =3D p_unit_id AND project_id =3D p_project_id AND ord =3D ANY(p_criteria) ORDER BY ord LOOP IF r.continuous THEN -- Continuous variables SELECT * FROM dt.p_bin_continuous(r.ord, r.nan_behavior, r.null_behavior, = p_min_population, r.max_p_value, r.max_level, r.monotone, r.dir, v_df) INTO v_bins, v_bounds, v_nodes; ELSE -- Discrete variables SELECT * FROM dt.p_bin_discrete(r.ord, p_min_population, r.max_p_value, v_df) INTO v_bins, v_bounds, v_nodes; END IF; -- Check if no split CONTINUE WHEN v_bins IS NULL OR array_length(v_bins, 1) =3D 1; -- Calculate AR v_ar :=3D pd.p_calc_ar(v_bins); IF v_ar > v_best_ar THEN v_best_ord :=3D r.ord; v_best_bounds :=3D v_bounds; v_best_ar :=3D v_ar; v_best_cont :=3D r.continuous; END IF; END LOOP; -- If no AR improvement then don't split IF v_best_bounds IS NULL OR array_length(v_best_bounds, 1) <=3D 1 OR = v_best_ar <=3D p_min_ar THEN p_tree_nodes :=3D p_tree_nodes || v_node; RETURN; END IF; -- Set the node child_ord and ar v_node.child_ord :=3D v_best_ord; v_node.child_discr :=3D NOT v_best_cont; v_node.ar :=3D v_best_ar; -- Add the node p_tree_nodes :=3D p_tree_nodes || v_node; -- Build children nodes FOR i IN 1..array_length(v_best_bounds, 1) LOOP v_bound :=3D v_best_bounds[i]; v_node_view :=3D v_view || ' AND ind_vars[' || v_best_ord || ']' || CASE WHEN (v_bound).bound IS NULL THEN ' IS NULL' WHEN (v_bound).bound =3D 'NaN'::float THEN '=3D''NaN''::float' WHEN NOT v_best_cont THEN '=3D' || (v_bound).bound WHEN i =3D 1 THEN '<=3D' ||=20 CASE WHEN (v_bound).bound =3D 'Infinity'::float THEN '''Infinity''::float' ELSE (v_bound).bound::text END WHEN (v_bound).bound =3D 'Infinity'::float THEN '>' || (v_best_bounds[i - 1]).bound ELSE '>' || (v_best_bounds[i - 1]).bound || ' AND ind_vars[' || = v_best_ord || ']<=3D' || (v_bound).bound END; p_tree_nodes :=3D dt.p_create_node( p_unit_id, p_project_id, p_sample, p_tree_ord, p_in_forest, CASE WHEN p_one_node_per_crit THEN array_remove(p_criteria, v_best_ord) ELSE p_criteria END, p_one_node_per_crit, p_min_population, p_max_level, p_min_ar, v_best_ord, (v_best_bounds[i]).bound, v_id || = to_char(i, 'FM00'), v_node_view, p_tree_nodes ); END LOOP; END; $BODY$ LANGUAGE plpgsql VOLATILE COST 100; =20 ------=_NextPart_000_0476_01D3A1AD.CEC18700--