From 2f7f61da38922c5a7f3c3dd6cfccae462520b6e8 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Wed, 26 Aug 2026 19:32:06 +0000 Subject: [PATCH] chore: update benchmark metrics (from release v1.00.28) [run ci] --- benchmark/benchmark_metrics.csv | 1 + ...0826_R_v1.00.28_vs_20260807_R_v1.00.27.csv | 46 + benchmark/metrics/20260826_R_v1.00.28.csv | 9810 +++++++++++++++++ 3 files changed, 9857 insertions(+) create mode 100644 benchmark/comparisons/comparison_20260826_R_v1.00.28_vs_20260807_R_v1.00.27.csv create mode 100644 benchmark/metrics/20260826_R_v1.00.28.csv diff --git a/benchmark/benchmark_metrics.csv b/benchmark/benchmark_metrics.csv index 923c62014..afcee99f9 100644 --- a/benchmark/benchmark_metrics.csv +++ b/benchmark/benchmark_metrics.csv @@ -3,3 +3,4 @@ run,total_questions,total_time_min,pyd_avg_time,pyd_min_time,pyd_max_time 20260629_R_v1.00.25,45,109.19,26.22,0.72,264.35 20260727_R_v1.00.26,45,111.69,24.94,0.61,300.48 20260807_R_v1.00.27,45,104.15,24.12,0.61,268.41 +20260826_R_v1.00.28,45,101.31,23.01,0.56,254.2 diff --git a/benchmark/comparisons/comparison_20260826_R_v1.00.28_vs_20260807_R_v1.00.27.csv b/benchmark/comparisons/comparison_20260826_R_v1.00.28_vs_20260807_R_v1.00.27.csv new file mode 100644 index 000000000..f27b89ca1 --- /dev/null +++ b/benchmark/comparisons/comparison_20260826_R_v1.00.28_vs_20260807_R_v1.00.27.csv @@ -0,0 +1,46 @@ +index,benchmark,question_id,pydough_exec_time_previous,pydough_exec_time_current,improvement_pct,status +1,TPCH,Q1,25.06850677500006,24.829848311999967,0.952%,improved +2,TPCH,Q2,0.6084700490000614,0.5649615059999178,7.15%,improved +3,TPCH,Q3,21.20643416300004,26.35687423399986,-24.287%,regressed +4,TPCH,Q4,27.311248250000062,26.49952643100005,2.972%,improved +5,TPCH,Q5,10.197431784999935,13.088302053000008,-28.349%,regressed +6,TPCH,Q6,9.941443223000078,3.950886373000003,60.258%,improved +7,TPCH,Q7,29.013338558999976,23.196946533999835,20.047%,improved +8,TPCH,Q8,17.35637556300003,12.857401886000162,25.921%,improved +9,TPCH,Q9,25.802307257999928,22.865245553000022,11.383%,improved +10,TPCH,Q10,12.679014329999973,7.343343968999989,42.083%,improved +11,TPCH,Q11,5.184100038999986,7.639850938000109,-47.371%,regressed +12,TPCH,Q12,9.90566266399992,5.093245161999903,48.582%,improved +13,TPCH,Q13,5.480319683000062,5.255456644999867,4.103%,improved +14,TPCH,Q14,11.197756415000184,6.790599230999987,39.358%,improved +15,TPCH,Q15,12.194246138999915,5.523427473000083,54.705%,improved +16,TPCH,Q16,2.5512964810000085,2.546066715000052,0.205%,improved +17,TPCH,Q17,8.815662945999975,3.27963325599967,62.798%,improved +18,TPCH,Q18,39.759058764999736,42.697238967999965,-7.39%,regressed +19,TPCH,Q19,4.206930775999808,4.05090557099993,3.709%,improved +20,TPCH,Q20,12.878718746999766,12.485393134000333,3.054%,improved +21,TPCH,Q21,268.41369304,254.20092595000008,5.295%,improved +22,TPCH,Q22,5.265749641999719,4.82431747299961,8.383%,improved +23,TPCDS,Q1,4.660958377000043,4.544565095000053,2.497%,improved +24,TPCDS,Q2,23.62430960399979,23.590702539000176,0.142%,improved +25,TPCDS,Q3,20.245960795999963,19.803773456999807,2.184%,improved +26,TPCDS,Q6,14.378902113000096,14.18810382599986,1.327%,improved +27,TPCDS,Q7,14.467770669999936,14.425270048999664,0.294%,improved +28,TPCDS,Q8,14.472310339999694,14.664676814999892,-1.329%,regressed +29,TPCDS,Q9,67.08265229200015,67.12777924800002,-0.067%,regressed +30,TPCDS,Q10,29.627121912999883,30.08664094899996,-1.551%,regressed +31,TPCDS,Q11,46.697003020999546,47.644232835000366,-2.028%,regressed +32,TPCDS,Q12,2.9589492029999747,2.9522780819997934,0.225%,improved +33,TPCDS,Q13,14.634276736000174,14.437903025000196,1.342%,improved +34,TPCDS,Q15,10.639273803999458,10.79016644999956,-1.418%,regressed +35,TPCDS,Q18,13.886652879999929,13.692958495999846,1.395%,improved +36,TPCDS,Q19,14.817367607000053,14.146070523999695,4.53%,improved +37,TPCDS,Q20,20.12961393400019,20.14119873300024,-0.058%,regressed +38,TPCDS,Q21,19.98257398199985,19.86378170199987,0.594%,improved +39,TPCDS,Q22,22.282351228000152,22.05169408399979,1.035%,improved +40,TPCDS,Q26,10.747943512999882,10.653942116000508,0.875%,improved +41,TPCDS,Q27,14.517895015999784,14.47944011600066,0.265%,improved +42,TPCDS,Q28,81.11587133400008,80.91520609300005,0.247%,improved +43,TPCDS,Q29,25.981297467999863,25.825060182000016,0.601%,improved +44,TPCDS,Q30,4.644636609999907,4.477377752000393,3.601%,improved +45,TPCDS,Q31,28.976695943000777,29.021674433000044,-0.155%,regressed diff --git a/benchmark/metrics/20260826_R_v1.00.28.csv b/benchmark/metrics/20260826_R_v1.00.28.csv new file mode 100644 index 000000000..2a1cd600c --- /dev/null +++ b/benchmark/metrics/20260826_R_v1.00.28.csv @@ -0,0 +1,9810 @@ +,index,benchmark,question_id,ground_truth,pydough_code,pydough_sql,exec_time,pydough_exec_time,exec_plan,pydough_exec_plan,status +0,1,TPCH,Q1,"SELECT + l_returnflag, + l_linestatus, + SUM(l_quantity) AS sum_qty, + SUM(l_extendedprice) AS sum_base_price, + SUM(l_extendedprice * (1 - l_discount)) AS sum_disc_price, + SUM(l_extendedprice * (1 - l_discount) * (1 + l_tax)) AS sum_charge, + AVG(l_quantity) AS avg_qty, + AVG(l_extendedprice) AS avg_price, + AVG(l_discount) AS avg_disc, + COUNT(*) AS count_order +FROM + tpch.lineitem +WHERE + l_shipdate <= DATE '1998-12-01' - INTERVAL '90 days' +GROUP BY + l_returnflag, + l_linestatus +ORDER BY + l_returnflag, + l_linestatus;","result = ( + lines.WHERE(ship_date <= DATETIME('1998-12-1', '-90 days')) + .PARTITION(name=""groups"", by=(return_flag, status)) + .CALCULATE( + L_RETURNFLAG=return_flag, + L_LINESTATUS=status, + SUM_QTY=SUM(lines.quantity), + SUM_BASE_PRICE=SUM(lines.extended_price), + SUM_DISC_PRICE=SUM(lines.extended_price * (1 - lines.discount)), + SUM_CHARGE=SUM( + lines.extended_price * (1 - lines.discount) * (1 + lines.tax) + ), + AVG_QTY=AVG(lines.quantity), + AVG_PRICE=AVG(lines.extended_price), + AVG_DISC=AVG(lines.discount), + COUNT_ORDER=COUNT(lines), + ) + .ORDER_BY(L_RETURNFLAG.ASC(), L_LINESTATUS.ASC()) + )","SELECT + l_returnflag AS L_RETURNFLAG, + l_linestatus AS L_LINESTATUS, + COALESCE(SUM(l_quantity), 0) AS SUM_QTY, + COALESCE(SUM(l_extendedprice), 0) AS SUM_BASE_PRICE, + COALESCE(SUM(l_extendedprice * ( + 1 - l_discount + )), 0) AS SUM_DISC_PRICE, + COALESCE(SUM(l_extendedprice * ( + 1 - l_discount + ) * ( + 1 + l_tax + )), 0) AS SUM_CHARGE, + AVG(CAST(l_quantity AS DECIMAL)) AS AVG_QTY, + AVG(CAST(l_extendedprice AS DECIMAL)) AS AVG_PRICE, + AVG(CAST(l_discount AS DECIMAL)) AS AVG_DISC, + COUNT(*) AS COUNT_ORDER +FROM tpch.lineitem +WHERE + l_shipdate <= CAST('1998-09-02' AS DATE) +GROUP BY + 1, + 2 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST",25.879578303000017,24.829848311999967,"Finalize GroupAggregate (cost=1685201.13..1698235.12 rows=40000 width=248) (actual time=24764.324..24770.032 rows=4 loops=1) + Group Key: l_returnflag, l_linestatus + -> Gather Merge (cost=1685201.13..1694535.12 rows=80000 width=248) (actual time=24764.286..24769.964 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1684201.11..1684301.11 rows=40000 width=248) (actual time=24747.905..24747.906 rows=4 loops=3) + Sort Key: l_returnflag, l_linestatus + Sort Method: quicksort Memory: 27kB + Worker 0: Sort Method: quicksort Memory: 27kB + Worker 1: Sort Method: quicksort Memory: 27kB + -> Partial HashAggregate (cost=1593260.22..1676492.06 rows=40000 width=248) (actual time=24747.855..24747.876 rows=4 loops=3) + Group Key: l_returnflag, l_linestatus + Planned Partitions: 8 Batches: 1 Memory Usage: 217kB + Worker 0: Batches: 1 Memory Usage: 217kB + Worker 1: Batches: 1 Memory Usage: 217kB + -> Parallel Seq Scan on lineitem (cost=0.00..1098328.25 rows=3010993 width=88) (actual time=222.483..3467.731 rows=19714203 loops=3) + Filter: (l_shipdate <= '1998-09-02 00:00:00'::timestamp without time zone) + Rows Removed by Filter: 281148 +Planning Time: 0.117 ms +JIT: + Functions: 27 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.032 ms, Inlining 174.029 ms, Optimization 280.098 ms, Emission 213.339 ms, Total 670.497 ms +Execution Time: 24770.993 ms","Finalize GroupAggregate (cost=1700456.10..1714290.08 rows=40000 width=248) (actual time=26320.600..26326.386 rows=4 loops=1) + Group Key: l_returnflag, l_linestatus + -> Gather Merge (cost=1700456.10..1709790.08 rows=80000 width=248) (actual time=26320.560..26326.298 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1699456.07..1699556.07 rows=40000 width=248) (actual time=26307.099..26307.100 rows=4 loops=3) + Sort Key: l_returnflag NULLS FIRST, l_linestatus NULLS FIRST + Sort Method: quicksort Memory: 27kB + Worker 0: Sort Method: quicksort Memory: 27kB + Worker 1: Sort Method: quicksort Memory: 27kB + -> Partial HashAggregate (cost=1608315.19..1691747.03 rows=40000 width=248) (actual time=26307.050..26307.071 rows=4 loops=3) + Group Key: l_returnflag, l_linestatus + Planned Partitions: 8 Batches: 1 Memory Usage: 225kB + Worker 0: Batches: 1 Memory Usage: 225kB + Worker 1: Batches: 1 Memory Usage: 225kB + -> Parallel Seq Scan on lineitem (cost=0.00..1098328.25 rows=3010993 width=88) (actual time=236.308..3489.404 rows=19714203 loops=3) + Filter: (l_shipdate <= '1998-09-02'::date) + Rows Removed by Filter: 281148 +Planning Time: 0.131 ms +JIT: + Functions: 27 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.068 ms, Inlining 158.690 ms, Optimization 304.796 ms, Emission 245.433 ms, Total 711.987 ms +Execution Time: 26327.460 ms",SUCCESS +1,2,TPCH,Q2,"SELECT + s.s_acctbal, + s.s_name, + n.n_name, + p.p_partkey, + p.p_mfgr, + s.s_address, + s.s_phone, + s.s_comment +FROM + tpch.part p +JOIN tpch.partsupp ps + ON p.p_partkey = ps.ps_partkey +JOIN tpch.supplier s + ON s.s_suppkey = ps.ps_suppkey +JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey +JOIN tpch.region r + ON n.n_regionkey = r.r_regionkey +WHERE + p.p_size = 15 + AND p.p_type LIKE '%BRASS' + AND r.r_name = 'EUROPE' + AND ps.ps_supplycost = ( + SELECT + MIN(ps2.ps_supplycost) + FROM + tpch.partsupp ps2 + JOIN tpch.supplier s2 + ON s2.s_suppkey = ps2.ps_suppkey + JOIN tpch.nation n2 + ON s2.s_nationkey = n2.n_nationkey + JOIN tpch.region r2 + ON n2.n_regionkey = r2.r_regionkey + WHERE + ps2.ps_partkey = p.p_partkey + AND r2.r_name = 'EUROPE' + ) +ORDER BY + s.s_acctbal DESC, + n.n_name, + s.s_name, + p.p_partkey +LIMIT 10;","result = ( + parts.WHERE(ENDSWITH(part_type, ""BRASS"") & (size == 15)) + .CALCULATE(P_PARTKEY=key, P_MFGR=manufacturer) + .supply_records.WHERE(supplier.nation.region.name == ""EUROPE"") + .BEST(by=supply_cost.ASC(), per=""parts"", allow_ties=True) + .CALCULATE( + S_ACCTBAL=supplier.account_balance, + S_NAME=supplier.name, + N_NAME=supplier.nation.name, + P_PARTKEY=P_PARTKEY, + P_MFGR=P_MFGR, + S_ADDRESS=supplier.address, + S_PHONE=supplier.phone, + S_COMMENT=supplier.comment, + ) + .TOP_K( + 10, + by=(S_ACCTBAL.DESC(), N_NAME.ASC(), S_NAME.ASC(), P_PARTKEY.ASC()), + ) + )","WITH _t AS ( + SELECT + nation.n_name, + part.p_mfgr, + part.p_partkey, + supplier.s_acctbal, + supplier.s_address, + supplier.s_comment, + supplier.s_name, + supplier.s_phone, + RANK() OVER (PARTITION BY partsupp.ps_partkey ORDER BY partsupp.ps_supplycost) AS _w + FROM tpch.part AS part + JOIN tpch.partsupp AS partsupp + ON part.p_partkey = partsupp.ps_partkey + JOIN tpch.supplier AS supplier + ON partsupp.ps_suppkey = supplier.s_suppkey + JOIN tpch.nation AS nation + ON nation.n_nationkey = supplier.s_nationkey + JOIN tpch.region AS region + ON nation.n_regionkey = region.r_regionkey AND region.r_name = 'EUROPE' + WHERE + part.p_size = 15 AND part.p_type LIKE '%BRASS' +) +SELECT + s_acctbal AS S_ACCTBAL, + s_name AS S_NAME, + n_name AS N_NAME, + p_partkey AS P_PARTKEY, + p_mfgr AS P_MFGR, + s_address AS S_ADDRESS, + s_phone AS S_PHONE, + s_comment AS S_COMMENT +FROM _t +WHERE + _w = 1 +ORDER BY + 1 DESC NULLS LAST, + 3 NULLS FIRST, + 2 NULLS FIRST, + 4 NULLS FIRST +LIMIT 10",205.708896223,0.5649615059999178,"Limit (cost=356406.09..356406.10 rows=1 width=216) (actual time=3005.648..3006.736 rows=10 loops=1) + -> Sort (cost=356406.09..356406.10 rows=1 width=216) (actual time=2982.880..2983.968 rows=10 loops=1) + Sort Key: s.s_acctbal DESC, n.n_name, s.s_name, p.p_partkey + Sort Method: top-N heapsort Memory: 29kB + -> Merge Join (cost=237449.34..356406.08 rows=1 width=216) (actual time=2144.777..2982.085 rows=4667 loops=1) + Merge Cond: (p.p_partkey = ps.ps_partkey) + Join Filter: (ps.ps_supplycost = (SubPlan 1)) + Rows Removed by Join Filter: 1684 + -> Gather Merge (cost=1000.45..83645.76 rows=8709 width=19) (actual time=104.739..136.586 rows=7854 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Index Scan using part_pkey on part p (cost=0.43..81640.50 rows=3629 width=19) (actual time=3.067..675.303 rows=2618 loops=3) + Filter: (((p_type)::text ~~ '%BRASS'::text) AND (p_size = 15)) + Rows Removed by Filter: 664049 + -> Materialize (cost=236439.40..236647.12 rows=41544 width=207) (actual time=2038.089..2385.059 rows=1602443 loops=1) + -> Sort (cost=236439.40..236543.26 rows=41544 width=207) (actual time=2038.083..2215.350 rows=1602443 loops=1) + Sort Key: ps.ps_partkey + Sort Method: external merge Disk: 253040kB + -> Gather (cost=3976.60..229132.98 rows=41544 width=207) (actual time=47.990..1386.676 rows=1602640 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2976.60..223978.58 rows=17310 width=207) (actual time=30.810..1369.027 rows=534213 loops=3) + Hash Cond: (ps.ps_suppkey = s.s_suppkey) + -> Parallel Seq Scan on partsupp ps (cost=0.00..208400.08 rows=3333408 width=14) (actual time=0.233..867.472 rows=2666667 loops=3) + -> Parallel Hash (cost=2972.74..2972.74 rows=309 width=201) (actual time=30.143..30.146 rows=6678 loops=3) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 4120kB + -> Hash Join (cost=24.81..2972.74 rows=309 width=201) (actual time=12.555..22.120 rows=6678 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=137) (actual time=0.007..3.112 rows=33333 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=12.525..12.527 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=12.515..12.522 rows=5 loops=3) + Hash Cond: (n.n_regionkey = r.r_regionkey) + -> Seq Scan on nation n (cost=0.00..11.90 rows=190 width=76) (actual time=0.074..0.076 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=12.413..12.413 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region r (cost=0.00..12.38 rows=1 width=4) (actual time=12.404..12.405 rows=1 loops=3) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 4 + SubPlan 1 + -> Aggregate (cost=198.80..198.81 rows=1 width=32) (actual time=0.053..0.053 rows=1 loops=6351) + -> Nested Loop (cost=1.01..198.80 rows=1 width=6) (actual time=0.042..0.052 rows=2 loops=6351) + -> Nested Loop (cost=0.87..191.01 rows=18 width=10) (actual time=0.036..0.048 rows=4 loops=6351) + -> Nested Loop (cost=0.72..188.08 rows=18 width=10) (actual time=0.035..0.044 rows=4 loops=6351) + -> Index Scan using partsupp_pkey on partsupp ps2 (cost=0.43..38.50 rows=18 width=10) (actual time=0.032..0.032 rows=4 loops=6351) + Index Cond: (ps_partkey = p.p_partkey) + -> Index Scan using supplier_pkey on supplier s2 (cost=0.29..8.31 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=25404) + Index Cond: (s_suppkey = ps2.ps_suppkey) + -> Index Scan using nation_pkey on nation n2 (cost=0.14..0.16 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=25404) + Index Cond: (n_nationkey = s2.s_nationkey) + -> Index Scan using region_pkey on region r2 (cost=0.14..0.42 rows=1 width=4) (actual time=0.001..0.001 rows=0 loops=25404) + Index Cond: (r_regionkey = n2.n_regionkey) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 1 +Planning Time: 3.120 ms +JIT: + Functions: 133 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 7.444 ms, Inlining 0.000 ms, Optimization 2.800 ms, Emission 63.925 ms, Total 74.168 ms +Execution Time: 3040.060 ms","Limit (cost=156173.37..156173.38 rows=1 width=216) (actual time=235.328..241.207 rows=10 loops=1) + -> Sort (cost=156173.37..156173.38 rows=1 width=216) (actual time=218.993..224.871 rows=10 loops=1) + Sort Key: _t.s_acctbal DESC NULLS LAST, _t.n_name NULLS FIRST, _t.s_name NULLS FIRST, _t.p_partkey NULLS FIRST + Sort Method: top-N heapsort Memory: 29kB + -> Subquery Scan on _t (cost=156146.85..156173.36 rows=1 width=216) (actual time=212.873..223.645 rows=4667 loops=1) + Filter: (_t._w = 1) + -> WindowAgg (cost=156146.85..156171.10 rows=181 width=234) (actual time=212.865..223.178 rows=4667 loops=1) + Run Condition: (rank() OVER (?) <= 1) + -> Gather Merge (cost=156146.85..156167.93 rows=181 width=226) (actual time=212.828..219.956 rows=6351 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=155146.83..155147.02 rows=75 width=226) (actual time=197.646..197.767 rows=2117 loops=3) + Sort Key: partsupp.ps_partkey, partsupp.ps_supplycost + Sort Method: quicksort Memory: 418kB + Worker 0: Sort Method: quicksort Memory: 401kB + Worker 1: Sort Method: quicksort Memory: 619kB + -> Parallel Hash Join (cost=2977.03..155144.50 rows=75 width=226) (actual time=31.089..196.291 rows=2117 loops=3) + Hash Cond: (partsupp.ps_suppkey = supplier.s_suppkey) + -> Nested Loop (cost=0.43..152113.02 rows=14517 width=33) (actual time=0.144..161.826 rows=10472 loops=3) + -> Parallel Seq Scan on part (cost=0.00..49694.38 rows=3629 width=19) (actual time=0.091..129.762 rows=2618 loops=3) + Filter: (((p_type)::text ~~ '%BRASS'::text) AND (p_size = 15)) + Rows Removed by Filter: 664049 + -> Index Scan using partsupp_pkey on partsupp (cost=0.43..28.04 rows=18 width=14) (actual time=0.010..0.011 rows=4 loops=7854) + Index Cond: (ps_partkey = part.p_partkey) + -> Parallel Hash (cost=2972.74..2972.74 rows=309 width=201) (actual time=30.586..30.589 rows=6678 loops=3) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 4120kB + -> Hash Join (cost=24.81..2972.74 rows=309 width=201) (actual time=10.971..20.492 rows=6678 loops=3) + Hash Cond: (supplier.s_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on supplier (cost=0.00..2724.24 rows=58824 width=137) (actual time=0.008..3.180 rows=33333 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=10.947..10.949 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=10.940..10.945 rows=5 loops=3) + Hash Cond: (nation.n_regionkey = region.r_regionkey) + -> Seq Scan on nation (cost=0.00..11.90 rows=190 width=76) (actual time=0.014..0.015 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=10.872..10.873 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region (cost=0.00..12.38 rows=1 width=4) (actual time=10.865..10.865 rows=1 loops=3) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 4 +Planning Time: 0.609 ms +JIT: + Functions: 113 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 4.813 ms, Inlining 0.000 ms, Optimization 2.216 ms, Emission 46.811 ms, Total 53.840 ms +Execution Time: 242.662 ms",SUCCESS +2,3,TPCH,Q3,"SELECT + l.l_orderkey, + SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue, + o.o_orderdate, + o.o_shippriority +FROM + tpch.customer c +JOIN tpch.orders o + ON c.c_custkey = o.o_custkey +JOIN tpch.lineitem l + ON l.l_orderkey = o.o_orderkey +WHERE + c.c_mktsegment = 'BUILDING' + AND o.o_orderdate < DATE '1995-03-15' + AND l.l_shipdate > DATE '1995-03-15' +GROUP BY + l.l_orderkey, + o.o_orderdate, + o.o_shippriority +ORDER BY + revenue DESC, + o.o_orderdate +LIMIT 10;","result = ( + orders.CALCULATE(order_date, ship_priority) + .WHERE( + (customer.market_segment == ""BUILDING"") + & (order_date < DATETIME('1995-3-15')) + ) + .lines.WHERE(ship_date > DATETIME('1995-3-15')) + .PARTITION(name=""groups"", by=(order_key, order_date, ship_priority)) + .CALCULATE( + L_ORDERKEY=order_key, + REVENUE=SUM(lines.extended_price * (1 - lines.discount)), + O_ORDERDATE=order_date, + O_SHIPPRIORITY=ship_priority, + ) + .TOP_K(10, by=(REVENUE.DESC(), O_ORDERDATE.ASC(), L_ORDERKEY.ASC())) + )","SELECT + lineitem.l_orderkey AS L_ORDERKEY, + COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS REVENUE, + orders.o_orderdate AS O_ORDERDATE, + orders.o_shippriority AS O_SHIPPRIORITY +FROM tpch.orders AS orders +JOIN tpch.customer AS customer + ON customer.c_custkey = orders.o_custkey AND customer.c_mktsegment = 'BUILDING' +JOIN tpch.lineitem AS lineitem + ON lineitem.l_orderkey = orders.o_orderkey + AND lineitem.l_shipdate > CAST('1995-03-15' AS DATE) +WHERE + orders.o_orderdate < CAST('1995-03-15' AS DATE) +GROUP BY + 1, + 3, + 4 +ORDER BY + 2 DESC NULLS LAST, + 3 NULLS FIRST, + 1 NULLS FIRST +LIMIT 10",28.58396417400013,26.35687423399986,"Limit (cost=1542836.70..1542836.73 rows=10 width=44) (actual time=26839.152..26953.915 rows=10 loops=1) + -> Sort (cost=1542836.70..1544065.19 rows=491394 width=44) (actual time=26622.168..26736.930 rows=10 loops=1) + Sort Key: (sum((l.l_extendedprice * ('1'::numeric - l.l_discount)))) DESC, o.o_orderdate + Sort Method: top-N heapsort Memory: 26kB + -> Finalize GroupAggregate (cost=1467548.29..1532217.85 rows=491394 width=44) (actual time=26443.265..26714.305 rows=114003 loops=1) + Group Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + -> Gather Merge (cost=1467548.29..1520956.73 rows=409496 width=44) (actual time=26443.254..26637.386 rows=114019 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1466548.27..1472690.71 rows=204748 width=44) (actual time=26426.327..26496.677 rows=38006 loops=3) + Group Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + -> Sort (cost=1466548.27..1467060.14 rows=204748 width=48) (actual time=26426.280..26437.318 rows=100705 loops=3) + Sort Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + Sort Method: external merge Disk: 3208kB + Worker 0: Sort Method: external merge Disk: 3976kB + Worker 1: Sort Method: external merge Disk: 3336kB + -> Parallel Hash Join (cost=331713.33..1442185.92 rows=204748 width=48) (actual time=18646.216..26385.770 rows=100705 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1098328.25 rows=3010993 width=40) (actual time=0.058..12247.303 rows=10778083 loops=3) + Filter: (l_shipdate > '1995-03-15'::date) + Rows Removed by Filter: 9217267 + -> Parallel Hash (cost=329659.08..329659.08 rows=164340 width=12) (actual time=4175.672..4175.676 rows=487308 loops=3) + Buckets: 131072 (originally 524288) Batches: 16 (originally 1) Memory Usage: 5344kB + -> Parallel Hash Join (cost=45150.86..329659.08 rows=164340 width=12) (actual time=547.272..3987.139 rows=487308 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..282393.54 rows=805588 width=16) (actual time=0.214..2872.394 rows=2429814 loops=3) + Filter: (o_orderdate < '1995-03-15'::date) + Rows Removed by Filter: 2570186 + -> Parallel Hash (cost=43557.01..43557.01 rows=127508 width=4) (actual time=545.719..545.720 rows=100092 loops=3) + Buckets: 524288 Batches: 1 Memory Usage: 15904kB + -> Parallel Seq Scan on customer c (cost=0.00..43557.01 rows=127508 width=4) (actual time=221.819..513.532 rows=100092 loops=3) + Filter: ((c_mktsegment)::text = 'BUILDING'::text) + Rows Removed by Filter: 399908 +Planning Time: 4.903 ms +JIT: + Functions: 94 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.887 ms, Inlining 167.307 ms, Optimization 428.767 ms, Emission 286.409 ms, Total 887.369 ms +Execution Time: 26960.924 ms","Limit (cost=1693744.95..1693744.98 rows=10 width=44) (actual time=13200.974..13381.734 rows=10 loops=1) + -> Sort (cost=1693744.95..1694947.95 rows=481200 width=44) (actual time=13004.061..13184.820 rows=10 loops=1) + Sort Key: (COALESCE(sum((lineitem.l_extendedprice * ('1'::numeric - lineitem.l_discount))), '0'::numeric)) DESC NULLS LAST, orders.o_orderdate NULLS FIRST, lineitem.l_orderkey NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> Finalize GroupAggregate (cost=1592266.26..1683346.40 rows=481200 width=44) (actual time=12862.480..13166.206 rows=114003 loops=1) + Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority + -> Gather Merge (cost=1592266.26..1669891.72 rows=595174 width=44) (actual time=12862.463..13103.418 rows=114019 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1591266.24..1600193.85 rows=297587 width=44) (actual time=12846.372..12911.499 rows=38006 loops=3) + Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority + -> Sort (cost=1591266.24..1592010.21 rows=297587 width=48) (actual time=12846.334..12856.550 rows=100705 loops=3) + Sort Key: lineitem.l_orderkey NULLS FIRST, orders.o_orderdate NULLS FIRST, orders.o_shippriority + Sort Method: external merge Disk: 2904kB + Worker 0: Sort Method: external merge Disk: 2896kB + Worker 1: Sort Method: external merge Disk: 4720kB + -> Parallel Hash Join (cost=394131.76..1555055.19 rows=297587 width=48) (actual time=11671.725..12808.081 rows=100705 loops=3) + Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1098328.25 rows=3010993 width=40) (actual time=0.050..5809.259 rows=10778083 loops=3) + Filter: (l_shipdate > '1995-03-15'::date) + Rows Removed by Filter: 9217267 + -> Parallel Hash (cost=383395.54..383395.54 rows=617618 width=12) (actual time=3838.479..3838.482 rows=487308 loops=3) + Buckets: 262144 Batches: 16 Memory Usage: 6400kB + -> Parallel Hash Join (cost=45150.86..383395.54 rows=617618 width=12) (actual time=498.519..3723.158 rows=487308 loops=3) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Parallel Seq Scan on orders (cost=0.00..330297.38 rows=3027536 width=16) (actual time=0.213..2633.677 rows=2429814 loops=3) + Filter: (o_orderdate < '1995-03-15'::date) + Rows Removed by Filter: 2570186 + -> Parallel Hash (cost=43557.01..43557.01 rows=127508 width=4) (actual time=496.996..496.996 rows=100092 loops=3) + Buckets: 524288 Batches: 1 Memory Usage: 15904kB + -> Parallel Seq Scan on customer (cost=0.00..43557.01 rows=127508 width=4) (actual time=202.345..465.573 rows=100092 loops=3) + Filter: ((c_mktsegment)::text = 'BUILDING'::text) + Rows Removed by Filter: 399908 +Planning Time: 1.555 ms +JIT: + Functions: 91 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.624 ms, Inlining 156.504 ms, Optimization 383.953 ms, Emission 263.568 ms, Total 808.648 ms +Execution Time: 13383.517 ms",SUCCESS +3,4,TPCH,Q4,"SELECT + o.o_orderpriority, + COUNT(*) AS order_count +FROM + tpch.orders o +WHERE + o.o_orderdate >= DATE '1993-07-01' + AND o.o_orderdate < DATE '1993-07-01' + INTERVAL '3 months' + AND EXISTS ( + SELECT + 1 + FROM + tpch.lineitem l + WHERE + l.l_orderkey = o.o_orderkey + AND l.l_commitdate < l.l_receiptdate + ) +GROUP BY + o.o_orderpriority +ORDER BY + o.o_orderpriority;","result = ( + orders.WHERE( + (YEAR(order_date) == 1993) + & (QUARTER(order_date) == 3) + & HAS(lines.WHERE(commit_date < receipt_date)) + ) + .PARTITION(name=""priorities"", by=order_priority) + .CALCULATE( + O_ORDERPRIORITY=order_priority, + ORDER_COUNT=COUNT(orders), + ) + .ORDER_BY(O_ORDERPRIORITY.ASC()) + )","WITH _u_0 AS ( + SELECT + l_orderkey AS _u_1 + FROM tpch.lineitem + WHERE + l_commitdate < l_receiptdate + GROUP BY + 1 +) +SELECT + orders.o_orderpriority AS O_ORDERPRIORITY, + COUNT(*) AS ORDER_COUNT +FROM tpch.orders AS orders +LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = orders.o_orderkey +WHERE + EXTRACT(MONTH FROM CAST(orders.o_orderdate AS TIMESTAMP)) IN (7, 8, 9) + AND EXTRACT(YEAR FROM CAST(orders.o_orderdate AS TIMESTAMP)) = 1993 + AND NOT _u_0._u_1 IS NULL +GROUP BY + 1 +ORDER BY + 1 NULLS FIRST",129.89146527599996,26.49952643100005,"Sort (cost=1277504.00..1277504.02 rows=5 width=17) (actual time=117985.872..117985.875 rows=5 loops=1) + Sort Key: o.o_orderpriority + Sort Method: quicksort Memory: 25kB + -> HashAggregate (cost=1277503.90..1277503.95 rows=5 width=17) (actual time=117985.861..117985.863 rows=5 loops=1) + Group Key: o.o_orderpriority + Batches: 1 Memory Usage: 24kB + -> Nested Loop (cost=1274471.79..1276165.82 rows=267615 width=9) (actual time=17641.216..117825.919 rows=526040 loops=1) + -> HashAggregate (cost=1274471.36..1274473.36 rows=200 width=4) (actual time=17637.376..35965.708 rows=13753474 loops=1) + Group Key: l.l_orderkey + Batches: 1093 Memory Usage: 10305kB Disk Usage: 1240176kB + -> Seq Scan on lineitem l (cost=0.00..1256405.40 rows=7226384 width=4) (actual time=94.661..6903.513 rows=37929348 loops=1) + Filter: (l_commitdate < l_receiptdate) + Rows Removed by Filter: 22056704 + -> Index Scan using orders_pkey on orders o (cost=0.43..8.46 rows=1 width=13) (actual time=0.006..0.006 rows=0 loops=13753474) + Index Cond: (o_orderkey = l.l_orderkey) + Filter: ((o_orderdate >= '1993-07-01'::date) AND (o_orderdate < '1993-10-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 1 +Planning Time: 0.214 ms +JIT: + Functions: 20 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.003 ms, Inlining 11.121 ms, Optimization 51.914 ms, Emission 35.755 ms, Total 100.793 ms +Execution Time: 118123.454 ms","GroupAggregate (cost=2395845.88..2395846.17 rows=5 width=17) (actual time=27827.712..27885.069 rows=5 loops=1) + Group Key: orders.o_orderpriority + -> Sort (cost=2395845.88..2395845.96 rows=33 width=9) (actual time=27813.300..27856.454 rows=526040 loops=1) + Sort Key: orders.o_orderpriority NULLS FIRST + Sort Method: external merge Disk: 6920kB + -> Hash Join (cost=1977763.49..2395845.04 rows=33 width=9) (actual time=25013.688..27740.497 rows=526040 loops=1) + Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) + -> Gather (cost=1000.00..417334.60 rows=1125 width=13) (actual time=141.013..1406.464 rows=573671 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on orders (cost=0.00..416222.10 rows=469 width=13) (actual time=114.636..1427.776 rows=191224 loops=3) + Filter: ((EXTRACT(year FROM (o_orderdate)::timestamp without time zone) = '1993'::numeric) AND (EXTRACT(month FROM (o_orderdate)::timestamp without time zone) = ANY ('{7,8,9}'::numeric[]))) + Rows Removed by Filter: 4808776 + -> Hash (cost=1969491.54..1969491.54 rows=443196 width=4) (actual time=24871.832..24871.891 rows=13753474 loops=1) + Buckets: 262144 (originally 262144) Batches: 128 (originally 4) Memory Usage: 6145kB + -> Group (cost=1863855.94..1969491.54 rows=443196 width=4) (actual time=20548.273..23347.795 rows=13753474 loops=1) + Group Key: lineitem.l_orderkey + -> Gather Merge (cost=1863855.94..1967275.56 rows=886392 width=4) (actual time=20548.248..22123.086 rows=13759070 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1862855.92..1863963.91 rows=443196 width=4) (actual time=20164.234..20511.898 rows=4586357 loops=3) + Sort Key: lineitem.l_orderkey + Sort Method: external merge Disk: 48312kB + Worker 0: Sort Method: external merge Disk: 45968kB + Worker 1: Sort Method: external merge Disk: 67560kB + -> Partial HashAggregate (cost=1745702.50..1815227.48 rows=443196 width=4) (actual time=11773.356..18961.874 rows=4586357 loops=3) + Group Key: lineitem.l_orderkey + Planned Partitions: 8 Batches: 281 Memory Usage: 10321kB Disk Usage: 350944kB + Worker 0: Batches: 281 Memory Usage: 10321kB Disk Usage: 334360kB + Worker 1: Batches: 233 Memory Usage: 10577kB Disk Usage: 490704kB + -> Parallel Seq Scan on lineitem (cost=0.00..1297862.50 rows=8331907 width=4) (actual time=72.429..6904.729 rows=12643116 loops=3) + Filter: ((l_orderkey IS NOT NULL) AND (l_commitdate < l_receiptdate)) + Rows Removed by Filter: 7352235 +Planning Time: 0.194 ms +JIT: + Functions: 50 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.206 ms, Inlining 294.165 ms, Optimization 164.452 ms, Emission 115.548 ms, Total 577.370 ms +Execution Time: 27913.350 ms",SUCCESS +4,5,TPCH,Q5,"SELECT + n.n_name, + SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue +FROM + tpch.customer c +JOIN tpch.orders o + ON c.c_custkey = o.o_custkey +JOIN tpch.lineitem l + ON l.l_orderkey = o.o_orderkey +JOIN tpch.supplier s + ON l.l_suppkey = s.s_suppkey + AND c.c_nationkey = s.s_nationkey +JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey +JOIN tpch.region r + ON n.n_regionkey = r.r_regionkey +WHERE + r.r_name = 'ASIA' + AND o.o_orderdate >= DATE '1994-01-01' + AND o.o_orderdate < DATE '1994-01-01' + INTERVAL '1 year' +GROUP BY + n.n_name +ORDER BY + revenue DESC;","selected_lines = ( + customers.orders.WHERE( + (order_date >= DATETIME('1994-1-1')) + & (order_date < DATETIME('1995-1-1')) + ) + .lines.WHERE(supplier.nation.name == nation_name) + .CALCULATE(value=extended_price * (1 - discount)) +) +result = (nations.CALCULATE(nation_name=name) + .WHERE(region.name == ""ASIA"") + .WHERE(HAS(selected_lines)) + .CALCULATE(N_NAME=name, REVENUE=SUM(selected_lines.value)) + .ORDER_BY(REVENUE.DESC()) +)","WITH _s11 AS ( + SELECT + nation.n_name, + supplier.s_suppkey + FROM tpch.supplier AS supplier + JOIN tpch.nation AS nation + ON nation.n_nationkey = supplier.s_nationkey +) +SELECT + MAX(nation.n_name) AS N_NAME, + COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS REVENUE +FROM tpch.nation AS nation +JOIN tpch.region AS region + ON nation.n_regionkey = region.r_regionkey AND region.r_name = 'ASIA' +JOIN tpch.customer AS customer + ON customer.c_nationkey = nation.n_nationkey +JOIN tpch.orders AS orders + ON customer.c_custkey = orders.o_custkey + AND orders.o_orderdate < CAST('1995-01-01' AS DATE) + AND orders.o_orderdate >= CAST('1994-01-01' AS DATE) +JOIN tpch.lineitem AS lineitem + ON lineitem.l_orderkey = orders.o_orderkey +JOIN _s11 AS _s11 + ON _s11.n_name = nation.n_name AND _s11.s_suppkey = lineitem.l_suppkey +GROUP BY + nation.n_nationkey +ORDER BY + 2 DESC NULLS LAST",12.76300771199999,13.088302053000007,"Sort (cost=1217108.45..1217108.93 rows=190 width=100) (actual time=11702.588..11773.473 rows=5 loops=1) + Sort Key: (sum((l.l_extendedprice * ('1'::numeric - l.l_discount)))) DESC + Sort Method: quicksort Memory: 25kB + -> Finalize GroupAggregate (cost=1217059.82..1217101.26 rows=190 width=100) (actual time=11696.539..11773.466 rows=5 loops=1) + Group Key: n.n_name + -> Gather Merge (cost=1217059.82..1217097.46 rows=190 width=100) (actual time=11693.959..11773.435 rows=10 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Partial GroupAggregate (cost=1216059.81..1216076.08 rows=190 width=100) (actual time=11671.154..11680.037 rows=5 loops=2) + Group Key: n.n_name + -> Sort (cost=1216059.81..1216062.59 rows=1111 width=80) (actual time=11668.940..11670.451 rows=36492 loops=2) + Sort Key: n.n_name + Sort Method: quicksort Memory: 2971kB + Worker 0: Sort Method: quicksort Memory: 3179kB + -> Parallel Hash Join (cost=1212833.57..1216003.61 rows=1111 width=80) (actual time=11609.793..11662.295 rows=36492 loops=2) + Hash Cond: ((s.s_suppkey = l.l_suppkey) AND (s.s_nationkey = c.c_nationkey)) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.177..39.925 rows=50000 loops=2) + -> Parallel Hash (cost=1212529.59..1212529.59 rows=20265 width=92) (actual time=11553.027..11553.040 rows=912928 loops=2) + Buckets: 131072 (originally 65536) Batches: 16 (originally 1) Memory Usage: 8960kB + -> Nested Loop (cost=44437.70..1212529.59 rows=20265 width=92) (actual time=1864.282..11204.642 rows=912928 loops=2) + -> Parallel Hash Join (cost=44437.14..393988.12 rows=5066 width=80) (actual time=1864.114..2283.034 rows=228386 loops=2) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..345920.06 rows=962618 width=8) (actual time=0.185..640.238 rows=1137960 loops=2) + Filter: ((o_orderdate >= '1994-01-01'::date) AND (o_orderdate < '1995-01-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 6362040 + -> Parallel Hash (cost=44396.01..44396.01 rows=3290 width=80) (actual time=1029.404..1029.407 rows=150135 loops=2) + Buckets: 131072 (originally 8192) Batches: 4 (originally 1) Memory Usage: 5216kB + -> Hash Join (cost=24.81..44396.01 rows=3290 width=80) (actual time=374.121..952.386 rows=150135 loops=2) + Hash Cond: (c.c_nationkey = n.n_nationkey) + -> Parallel Seq Scan on customer c (cost=0.00..41994.40 rows=625040 width=8) (actual time=0.164..500.035 rows=750000 loops=2) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=373.936..373.939 rows=5 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=373.930..373.934 rows=5 loops=2) + Hash Cond: (n.n_regionkey = r.r_regionkey) + -> Seq Scan on nation n (cost=0.00..11.90 rows=190 width=76) (actual time=0.076..0.078 rows=25 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=373.835..373.836 rows=1 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region r (cost=0.00..12.38 rows=1 width=4) (actual time=373.824..373.826 rows=1 loops=2) + Filter: ((r_name)::text = 'ASIA'::text) + Rows Removed by Filter: 4 + -> Index Scan using lineitem_pkey on lineitem l (cost=0.56..160.23 rows=135 width=20) (actual time=0.037..0.038 rows=4 loops=456771) + Index Cond: (l_orderkey = o.o_orderkey) +Planning Time: 4.274 ms +JIT: + Functions: 109 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.917 ms, Inlining 80.713 ms, Optimization 391.811 ms, Emission 275.230 ms, Total 753.671 ms +Execution Time: 11776.047 ms","Sort (cost=1217044.45..1217044.92 rows=190 width=68) (actual time=12303.038..12371.600 rows=5 loops=1) + Sort Key: (COALESCE(sum((lineitem.l_extendedprice * ('1'::numeric - lineitem.l_discount))), '0'::numeric)) DESC NULLS LAST + Sort Method: quicksort Memory: 25kB + -> Finalize GroupAggregate (cost=1217012.98..1217037.25 rows=190 width=68) (actual time=12296.148..12371.590 rows=5 loops=1) + Group Key: nation.n_nationkey + -> Gather Merge (cost=1217012.98..1217033.42 rows=146 width=68) (actual time=12293.387..12371.558 rows=10 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Partial GroupAggregate (cost=1216012.97..1216016.98 rows=146 width=68) (actual time=12265.398..12274.866 rows=5 loops=2) + Group Key: nation.n_nationkey + -> Sort (cost=1216012.97..1216013.33 rows=146 width=84) (actual time=12262.915..12264.710 rows=36492 loops=2) + Sort Key: nation.n_nationkey + Sort Method: quicksort Memory: 3113kB + Worker 0: Sort Method: quicksort Memory: 3135kB + -> Hash Join (cost=1212801.39..1216007.72 rows=146 width=84) (actual time=12044.517..12257.516 rows=36492 loops=2) + Hash Cond: ((supplier.s_nationkey = nation_1.n_nationkey) AND ((nation.n_name)::text = (nation_1.n_name)::text)) + -> Parallel Hash Join (cost=1212786.64..1215847.17 rows=27769 width=88) (actual time=11634.757..11771.165 rows=912928 loops=2) + Hash Cond: (supplier.s_suppkey = lineitem.l_suppkey) + -> Parallel Seq Scan on supplier (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.162..27.932 rows=50000 loops=2) + -> Parallel Hash (cost=1212533.32..1212533.32 rows=20265 width=88) (actual time=11592.404..11592.412 rows=912928 loops=2) + Buckets: 131072 (originally 65536) Batches: 16 (originally 1) Memory Usage: 8448kB + -> Nested Loop (cost=44437.70..1212533.32 rows=20265 width=88) (actual time=1412.721..11269.038 rows=912928 loops=2) + -> Parallel Hash Join (cost=44437.14..393988.12 rows=5066 width=76) (actual time=1412.551..1790.077 rows=228386 loops=2) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Parallel Seq Scan on orders (cost=0.00..345920.06 rows=962618 width=8) (actual time=0.190..631.754 rows=1137960 loops=2) + Filter: ((o_orderdate < '1995-01-01'::date) AND (o_orderdate >= '1994-01-01'::date)) + Rows Removed by Filter: 6362040 + -> Parallel Hash (cost=44396.01..44396.01 rows=3290 width=76) (actual time=589.686..589.691 rows=150135 loops=2) + Buckets: 262144 (originally 8192) Batches: 4 (originally 1) Memory Usage: 5728kB + -> Hash Join (cost=24.81..44396.01 rows=3290 width=76) (actual time=0.677..544.097 rows=150135 loops=2) + Hash Cond: (customer.c_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on customer (cost=0.00..41994.40 rows=625040 width=8) (actual time=0.548..472.752 rows=750000 loops=2) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=0.118..0.121 rows=5 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=0.112..0.117 rows=5 loops=2) + Hash Cond: (nation.n_regionkey = region.r_regionkey) + -> Seq Scan on nation (cost=0.00..11.90 rows=190 width=76) (actual time=0.005..0.006 rows=25 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.097..0.098 rows=1 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region (cost=0.00..12.38 rows=1 width=4) (actual time=0.093..0.094 rows=1 loops=2) + Filter: ((r_name)::text = 'ASIA'::text) + Rows Removed by Filter: 4 + -> Index Scan using lineitem_pkey on lineitem (cost=0.56..160.23 rows=135 width=20) (actual time=0.039..0.041 rows=4 loops=456771) + Index Cond: (l_orderkey = orders.o_orderkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=409.616..409.616 rows=25 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation nation_1 (cost=0.00..11.90 rows=190 width=72) (actual time=409.586..409.592 rows=25 loops=2) +Planning Time: 5.337 ms +JIT: + Functions: 123 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.775 ms, Inlining 102.298 ms, Optimization 434.147 ms, Emission 282.809 ms, Total 826.028 ms +Execution Time: 12373.671 ms",SUCCESS +5,6,TPCH,Q6,"SELECT + SUM(l.l_extendedprice * l.l_discount) AS revenue +FROM + tpch.lineitem l +WHERE + l.l_shipdate >= DATE '1994-01-01' + AND l.l_shipdate < DATE '1994-01-01' + INTERVAL '1 year' + AND l.l_discount BETWEEN 0.06 - 0.01 AND 0.06 + 0.01 + AND l.l_quantity < 24;","selected_lines = lines.WHERE( + (ship_date >= DATETIME('1994-1-1')) + & (ship_date < DATETIME('1995-1-1')) + & (0.05 <= discount) + & (discount <= 0.07) + & (quantity < 24) +).CALCULATE(amt=extended_price * discount) +result = TPCH.CALCULATE(REVENUE=SUM(selected_lines.amt))","SELECT + COALESCE(SUM(l_extendedprice * l_discount), 0) AS REVENUE +FROM tpch.lineitem +WHERE + l_discount <= 0.07 + AND l_discount >= 0.05 + AND l_quantity < 24 + AND l_shipdate < CAST('1995-01-01' AS DATE) + AND l_shipdate >= CAST('1994-01-01' AS DATE)",4.004583406000165,3.950886373000003,"Finalize Aggregate (cost=1551215.87..1551215.88 rows=1 width=32) (actual time=2943.478..2952.259 rows=1 loops=1) + -> Gather (cost=1551215.65..1551215.86 rows=2 width=32) (actual time=2943.284..2952.225 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1550215.65..1550215.66 rows=1 width=32) (actual time=2927.584..2927.585 rows=1 loops=3) + -> Parallel Seq Scan on lineitem l (cost=0.00..1547819.70 rows=479190 width=12) (actual time=130.252..2825.068 rows=379755 loops=3) + Filter: ((l_shipdate >= '1994-01-01'::date) AND (l_shipdate < '1995-01-01 00:00:00'::timestamp without time zone) AND (l_discount >= 0.05) AND (l_discount <= 0.07) AND (l_quantity < '24'::numeric)) + Rows Removed by Filter: 19615596 +Planning Time: 0.107 ms +JIT: + Functions: 17 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.855 ms, Inlining 176.988 ms, Optimization 127.971 ms, Emission 85.751 ms, Total 392.565 ms +Execution Time: 2952.819 ms","Finalize Aggregate (cost=1551215.87..1551215.88 rows=1 width=32) (actual time=3889.194..3897.683 rows=1 loops=1) + -> Gather (cost=1551215.65..1551215.86 rows=2 width=32) (actual time=3889.041..3897.653 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1550215.65..1550215.66 rows=1 width=32) (actual time=3875.637..3875.638 rows=1 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1547819.70 rows=479190 width=12) (actual time=124.321..3774.234 rows=379755 loops=3) + Filter: ((l_discount <= 0.07) AND (l_discount >= 0.05) AND (l_quantity < '24'::numeric) AND (l_shipdate < '1995-01-01'::date) AND (l_shipdate >= '1994-01-01'::date)) + Rows Removed by Filter: 19615596 +Planning Time: 0.078 ms +JIT: + Functions: 17 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.851 ms, Inlining 159.818 ms, Optimization 126.773 ms, Emission 86.352 ms, Total 374.794 ms +Execution Time: 3898.268 ms",SUCCESS +6,7,TPCH,Q7,"SELECT + supp_nation, + cust_nation, + l_year, + SUM(volume) AS revenue +FROM ( + SELECT + n1.n_name AS supp_nation, + n2.n_name AS cust_nation, + EXTRACT(YEAR FROM l.l_shipdate) AS l_year, + l.l_extendedprice * (1 - l.l_discount) AS volume + FROM + tpch.supplier s + JOIN tpch.lineitem l + ON s.s_suppkey = l.l_suppkey + JOIN tpch.orders o + ON o.o_orderkey = l.l_orderkey + JOIN tpch.customer c + ON c.c_custkey = o.o_custkey + JOIN tpch.nation n1 + ON s.s_nationkey = n1.n_nationkey + JOIN tpch.nation n2 + ON c.c_nationkey = n2.n_nationkey + WHERE + ( + (n1.n_name = 'FRANCE' AND n2.n_name = 'GERMANY') + OR + (n1.n_name = 'GERMANY' AND n2.n_name = 'FRANCE') + ) + AND l.l_shipdate BETWEEN DATE '1995-01-01' + AND DATE '1996-12-31' +) AS shipping +GROUP BY + supp_nation, + cust_nation, + l_year +ORDER BY + supp_nation, + cust_nation, + l_year;","result = ( + lines.CALCULATE( + supp_nation=supplier.nation.name, + cust_nation=order.customer.nation.name, + l_year=YEAR(ship_date), + volume=extended_price * (1 - discount), + ) + .WHERE( + ISIN(YEAR(ship_date), (1995, 1996)) + & ( + ((supp_nation == ""FRANCE"") & (cust_nation == ""GERMANY"")) + | ((supp_nation == ""GERMANY"") & (cust_nation == ""FRANCE"")) + ) + ) + .PARTITION(name=""groups"", by=(supp_nation, cust_nation, l_year)) + .CALCULATE( + SUPP_NATION=supp_nation, + CUST_NATION=cust_nation, + L_YEAR=l_year, + REVENUE=SUM(lines.volume), + ) + .ORDER_BY(SUPP_NATION.ASC(), CUST_NATION.ASC(), L_YEAR.ASC()) + )","WITH _s9 AS ( + SELECT + nation.n_name, + orders.o_orderkey + FROM tpch.orders AS orders + JOIN tpch.customer AS customer + ON customer.c_custkey = orders.o_custkey + JOIN tpch.nation AS nation + ON customer.c_nationkey = nation.n_nationkey + AND ( + nation.n_name = 'FRANCE' OR nation.n_name = 'GERMANY' + ) +) +SELECT + nation.n_name AS SUPP_NATION, + _s9.n_name AS CUST_NATION, + EXTRACT(YEAR FROM CAST(lineitem.l_shipdate AS TIMESTAMP)) AS L_YEAR, + COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS REVENUE +FROM tpch.lineitem AS lineitem +JOIN tpch.supplier AS supplier + ON lineitem.l_suppkey = supplier.s_suppkey +JOIN tpch.nation AS nation + ON nation.n_nationkey = supplier.s_nationkey +JOIN _s9 AS _s9 + ON ( + _s9.n_name = 'FRANCE' OR nation.n_name = 'FRANCE' + ) + AND ( + _s9.n_name = 'GERMANY' OR nation.n_name = 'GERMANY' + ) + AND _s9.o_orderkey = lineitem.l_orderkey + AND ( + nation.n_name = 'FRANCE' OR nation.n_name = 'GERMANY' + ) +WHERE + EXTRACT(YEAR FROM CAST(lineitem.l_shipdate AS TIMESTAMP)) IN (1995, 1996) +GROUP BY + 1, + 2, + 3 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST",15.487474054000131,23.196946533999835,"Finalize GroupAggregate (cost=1776497.02..1776630.67 rows=990 width=200) (actual time=11327.392..11562.977 rows=4 loops=1) + Group Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + -> Gather Merge (cost=1776497.02..1776605.52 rows=824 width=200) (actual time=11324.260..11562.930 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1775496.99..1775510.38 rows=412 width=200) (actual time=11302.698..11309.377 rows=4 loops=3) + Group Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + -> Sort (cost=1775496.99..1775498.02 rows=412 width=180) (actual time=11300.121..11301.122 rows=19455 loops=3) + Sort Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + Sort Method: quicksort Memory: 1844kB + Worker 0: Sort Method: quicksort Memory: 1872kB + Worker 1: Sort Method: quicksort Memory: 2125kB + -> Parallel Hash Join (cost=385874.59..1775479.10 rows=412 width=180) (actual time=9177.290..11288.787 rows=19455 loops=3) + Hash Cond: (l.l_suppkey = s.s_suppkey) + Join Filter: ((((n1.n_name)::text = 'FRANCE'::text) AND ((n2.n_name)::text = 'GERMANY'::text)) OR (((n1.n_name)::text = 'GERMANY'::text) AND ((n2.n_name)::text = 'FRANCE'::text))) + Rows Removed by Join Filter: 19550 + -> Parallel Hash Join (cost=382971.88..1772264.60 rows=80298 width=88) (actual time=8577.050..10617.495 rows=487923 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1360351.80 rows=7628357 width=24) (actual time=0.049..5435.479 rows=6076775 loops=3) + Filter: ((l_shipdate >= '1995-01-01'::date) AND (l_shipdate <= '1996-12-31'::date)) + Rows Removed by Filter: 13918576 + -> Parallel Hash (cost=382149.63..382149.63 rows=65780 width=72) (actual time=1891.062..1891.067 rows=401936 loops=3) + Buckets: 131072 (originally 262144) Batches: 8 (originally 1) Memory Usage: 8160kB + -> Parallel Hash Join (cost=43766.85..382149.63 rows=65780 width=72) (actual time=500.764..1769.672 rows=401936 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..314674.70 rows=6249070 width=8) (actual time=0.181..525.746 rows=5000000 loops=3) + -> Parallel Hash (cost=43684.61..43684.61 rows=6579 width=72) (actual time=500.488..500.490 rows=40156 loops=3) + Buckets: 131072 (originally 16384) Batches: 1 (originally 1) Memory Usage: 7616kB + -> Hash Join (cost=12.88..43684.61 rows=6579 width=72) (actual time=0.330..479.526 rows=40156 loops=3) + Hash Cond: (c.c_nationkey = n2.n_nationkey) + -> Parallel Seq Scan on customer c (cost=0.00..41994.40 rows=625040 width=8) (actual time=0.277..429.709 rows=500000 loops=3) + -> Hash (cost=12.85..12.85 rows=2 width=72) (actual time=0.037..0.038 rows=2 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n2 (cost=0.00..12.85 rows=2 width=72) (actual time=0.030..0.032 rows=2 loops=3) + Filter: (((n_name)::text = 'GERMANY'::text) OR ((n_name)::text = 'FRANCE'::text)) + Rows Removed by Filter: 23 + -> Parallel Hash (cost=2894.97..2894.97 rows=619 width=72) (actual time=600.002..600.004 rows=2670 loops=3) + Buckets: 8192 (originally 2048) Batches: 1 (originally 1) Memory Usage: 528kB + -> Hash Join (cost=12.88..2894.97 rows=619 width=72) (actual time=512.003..519.169 rows=2670 loops=3) + Hash Cond: (s.s_nationkey = n1.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.008..3.428 rows=33333 loops=3) + -> Hash (cost=12.85..12.85 rows=2 width=72) (actual time=511.973..511.974 rows=2 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n1 (cost=0.00..12.85 rows=2 width=72) (actual time=511.958..511.962 rows=2 loops=3) + Filter: (((n_name)::text = 'FRANCE'::text) OR ((n_name)::text = 'GERMANY'::text)) + Rows Removed by Filter: 23 +Planning Time: 2.031 ms +JIT: + Functions: 180 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.975 ms, Inlining 177.886 ms, Optimization 885.771 ms, Emission 472.589 ms, Total 1545.221 ms +Execution Time: 11565.990 ms","GroupAggregate (cost=1427753.10..1427763.04 rows=1 width=200) (actual time=10352.172..18363.906 rows=4 loops=1) + Group Key: nation.n_name, nation_1.n_name, EXTRACT(year FROM (lineitem.l_shipdate)::timestamp without time zone) + -> Nested Loop (cost=1427753.10..1427763.00 rows=1 width=180) (actual time=7647.711..18330.537 rows=58365 loops=1) + Join Filter: (nation_1.n_nationkey = customer.c_nationkey) + Rows Removed by Join Filter: 1401892 + -> Nested Loop (cost=1427752.67..1427757.82 rows=1 width=160) (actual time=7647.587..12305.542 rows=1460257 loops=1) + -> Gather Merge (cost=1427752.24..1427752.36 rows=1 width=160) (actual time=7647.530..8298.088 rows=1460257 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1426752.21..1426752.22 rows=1 width=160) (actual time=7480.546..7650.310 rows=486752 loops=3) + Sort Key: nation.n_name NULLS FIRST, nation_1.n_name NULLS FIRST, (EXTRACT(year FROM (lineitem.l_shipdate)::timestamp without time zone)) NULLS FIRST + Sort Method: external merge Disk: 22776kB + Worker 0: Sort Method: external merge Disk: 22824kB + Worker 1: Sort Method: external merge Disk: 37432kB + -> Parallel Hash Join (cost=2973.75..1426752.20 rows=1 width=160) (actual time=420.089..7042.247 rows=486752 loops=3) + Hash Cond: (lineitem.l_suppkey = supplier.s_suppkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1422841.10 rows=249957 width=24) (actual time=0.046..5774.610 rows=6076775 loops=3) + Filter: (EXTRACT(year FROM (l_shipdate)::timestamp without time zone) = ANY ('{1995,1996}'::numeric[])) + Rows Removed by Filter: 13918576 + -> Parallel Hash (cost=2973.73..2973.73 rows=1 width=144) (actual time=419.128..419.132 rows=2670 loops=3) + Buckets: 8192 (originally 1024) Batches: 1 (originally 1) Memory Usage: 632kB + -> Hash Join (cost=25.81..2973.73 rows=1 width=144) (actual time=353.679..382.232 rows=2670 loops=3) + Hash Cond: (supplier.s_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on supplier (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.153..25.502 rows=33333 loops=3) + -> Hash (cost=25.79..25.79 rows=1 width=144) (actual time=353.500..353.502 rows=2 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Nested Loop (cost=0.00..25.79 rows=1 width=144) (actual time=353.489..353.495 rows=2 loops=3) + Join Filter: ((((nation_1.n_name)::text = 'FRANCE'::text) OR ((nation.n_name)::text = 'FRANCE'::text)) AND (((nation_1.n_name)::text = 'GERMANY'::text) OR ((nation.n_name)::text = 'GERMANY'::text))) + Rows Removed by Join Filter: 2 + -> Seq Scan on nation (cost=0.00..12.85 rows=2 width=72) (actual time=353.458..353.460 rows=2 loops=3) + Filter: (((n_name)::text = 'FRANCE'::text) OR ((n_name)::text = 'GERMANY'::text)) + Rows Removed by Filter: 23 + -> Materialize (cost=0.00..12.86 rows=2 width=72) (actual time=0.012..0.013 rows=2 loops=6) + -> Seq Scan on nation nation_1 (cost=0.00..12.85 rows=2 width=72) (actual time=0.016..0.018 rows=2 loops=3) + Filter: (((n_name)::text = 'FRANCE'::text) OR ((n_name)::text = 'GERMANY'::text)) + Rows Removed by Filter: 23 + -> Index Scan using orders_pkey on orders (cost=0.43..5.46 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=1460257) + Index Cond: (o_orderkey = lineitem.l_orderkey) + -> Index Scan using customer_pkey on customer (cost=0.43..5.17 rows=1 width=8) (actual time=0.004..0.004 rows=1 loops=1460257) + Index Cond: (c_custkey = orders.o_custkey) +Planning Time: 3.760 ms +JIT: + Functions: 111 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.033 ms, Inlining 184.130 ms, Optimization 563.751 ms, Emission 312.439 ms, Total 1068.355 ms +Execution Time: 18368.944 ms",SUCCESS +7,8,TPCH,Q8,"SELECT + o_year, + SUM( + CASE + WHEN nation = 'BRAZIL' THEN volume + ELSE 0 + END + ) / SUM(volume) AS mkt_share +FROM ( + SELECT + EXTRACT(YEAR FROM o.o_orderdate) AS o_year, + l.l_extendedprice * (1 - l.l_discount) AS volume, + n2.n_name AS nation + FROM + tpch.part p + JOIN tpch.lineitem l + ON p.p_partkey = l.l_partkey + JOIN tpch.supplier s + ON s.s_suppkey = l.l_suppkey + JOIN tpch.orders o + ON o.o_orderkey = l.l_orderkey + JOIN tpch.customer c + ON c.c_custkey = o.o_custkey + JOIN tpch.nation n1 + ON c.c_nationkey = n1.n_nationkey + JOIN tpch.region r + ON n1.n_regionkey = r.r_regionkey + JOIN tpch.nation n2 + ON s.s_nationkey = n2.n_nationkey + WHERE + r.r_name = 'AMERICA' + AND o.o_orderdate BETWEEN DATE '1995-01-01' + AND DATE '1996-12-31' + AND p.p_type = 'ECONOMY ANODIZED STEEL' +) AS all_nations +GROUP BY + o_year +ORDER BY + o_year;","vol_metric = extended_price * (1 - discount) +is_brazilian = supplier.nation.name == ""BRAZIL"" +result = ( + lines.WHERE( + (part.part_type == ""ECONOMY ANODIZED STEEL"") + & ISIN(YEAR(order.order_date), (1995, 1996)) + & (order.customer.nation.region.name == ""AMERICA"") + ) + .CALCULATE( + O_YEAR=YEAR(order.order_date), + volume=vol_metric, + brazil_volume=IFF(is_brazilian, vol_metric, 0), + ) + .PARTITION(name=""years"", by=O_YEAR) + .CALCULATE( + O_YEAR, + MKT_SHARE=SUM(lines.brazil_volume) / SUM(lines.volume), + ) +)","SELECT + EXTRACT(YEAR FROM CAST(orders.o_orderdate AS TIMESTAMP)) AS O_YEAR, + CAST(COALESCE( + SUM( + CASE + WHEN nation_2.n_name = 'BRAZIL' + THEN lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + ) + ELSE 0 + END + ), + 0 + ) AS DOUBLE PRECISION) / COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS MKT_SHARE +FROM tpch.lineitem AS lineitem +JOIN tpch.part AS part + ON lineitem.l_partkey = part.p_partkey AND part.p_type = 'ECONOMY ANODIZED STEEL' +JOIN tpch.orders AS orders + ON EXTRACT(YEAR FROM CAST(orders.o_orderdate AS TIMESTAMP)) IN (1995, 1996) + AND lineitem.l_orderkey = orders.o_orderkey +JOIN tpch.customer AS customer + ON customer.c_custkey = orders.o_custkey +JOIN tpch.nation AS nation + ON customer.c_nationkey = nation.n_nationkey +JOIN tpch.region AS region + ON nation.n_regionkey = region.r_regionkey AND region.r_name = 'AMERICA' +JOIN tpch.supplier AS supplier + ON lineitem.l_suppkey = supplier.s_suppkey +JOIN tpch.nation AS nation_2 + ON nation_2.n_nationkey = supplier.s_nationkey +GROUP BY + 1",5.130334132999906,12.857401886000162,"Finalize GroupAggregate (cost=1749796.35..1749901.56 rows=734 width=64) (actual time=6033.086..6052.838 rows=2 loops=1) + Group Key: (EXTRACT(year FROM o.o_orderdate)) + -> Gather Merge (cost=1749796.35..1749879.23 rows=612 width=96) (actual time=6030.880..6052.807 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1748796.33..1748808.57 rows=306 width=96) (actual time=6013.840..6015.572 rows=2 loops=3) + Group Key: (EXTRACT(year FROM o.o_orderdate)) + -> Sort (cost=1748796.33..1748797.09 rows=306 width=112) (actual time=6011.793..6012.185 rows=8085 loops=3) + Sort Key: (EXTRACT(year FROM o.o_orderdate)) + Sort Method: quicksort Memory: 565kB + Worker 0: Sort Method: quicksort Memory: 577kB + Worker 1: Sort Method: quicksort Memory: 922kB + -> Hash Join (cost=445458.26..1748783.69 rows=306 width=112) (actual time=5951.863..6009.228 rows=8085 loops=3) + Hash Cond: (s.s_nationkey = n2.n_nationkey) + -> Nested Loop (cost=445443.98..1748767.83 rows=306 width=20) (actual time=5446.727..5501.367 rows=8085 loops=3) + -> Parallel Hash Join (cost=445443.69..1747160.09 rows=315 width=20) (actual time=5446.695..5483.723 rows=8085 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Hash Join (cost=47692.20..1348679.30 rows=194130 width=20) (actual time=70.997..4321.398 rows=134496 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235373.20 rows=24995720 width=24) (actual time=0.019..2018.364 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.31..47611.31 rows=6471 width=4) (actual time=70.794..70.795 rows=4484 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 704kB + -> Parallel Seq Scan on part p (cost=0.00..47611.31 rows=6471 width=4) (actual time=0.064..69.862 rows=4484 loops=3) + Filter: ((p_type)::text = 'ECONOMY ANODIZED STEEL'::text) + Rows Removed by Filter: 662183 + -> Parallel Hash (cost=397624.73..397624.73 rows=10141 width=8) (actual time=1076.512..1076.517 rows=303453 loops=3) + Buckets: 262144 (originally 32768) Batches: 8 (originally 1) Memory Usage: 6560kB + -> Parallel Hash Join (cost=44437.14..397624.73 rows=10141 width=8) (actual time=129.536..972.407 rows=303453 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..345920.06 rows=1926739 width=12) (actual time=0.033..553.984 rows=1519171 loops=3) + Filter: ((o_orderdate >= '1995-01-01'::date) AND (o_orderdate <= '1996-12-31'::date)) + Rows Removed by Filter: 3480829 + -> Parallel Hash (cost=44396.01..44396.01 rows=3290 width=4) (actual time=129.453..129.457 rows=99812 loops=3) + Buckets: 524288 (originally 8192) Batches: 1 (originally 1) Memory Usage: 19904kB + -> Hash Join (cost=24.81..44396.01 rows=3290 width=4) (actual time=0.173..104.513 rows=99812 loops=3) + Hash Cond: (c.c_nationkey = n1.n_nationkey) + -> Parallel Seq Scan on customer c (cost=0.00..41994.40 rows=625040 width=8) (actual time=0.107..54.045 rows=500000 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=4) (actual time=0.054..0.056 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=4) (actual time=0.045..0.051 rows=5 loops=3) + Hash Cond: (n1.n_regionkey = r.r_regionkey) + -> Seq Scan on nation n1 (cost=0.00..11.90 rows=190 width=8) (actual time=0.005..0.007 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.027..0.028 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region r (cost=0.00..12.38 rows=1 width=4) (actual time=0.023..0.023 rows=1 loops=3) + Filter: ((r_name)::text = 'AMERICA'::text) + Rows Removed by Filter: 4 + -> Index Scan using supplier_pkey on supplier s (cost=0.29..5.10 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=24254) + Index Cond: (s_suppkey = l.l_suppkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=505.099..505.099 rows=25 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation n2 (cost=0.00..11.90 rows=190 width=72) (actual time=505.067..505.075 rows=25 loops=3) +Planning Time: 1.142 ms +JIT: + Functions: 201 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.950 ms, Inlining 183.417 ms, Optimization 789.430 ms, Emission 542.812 ms, Total 1523.609 ms +Execution Time: 6055.031 ms","Finalize GroupAggregate (cost=468828.99..468832.63 rows=24 width=40) (actual time=12733.016..12741.448 rows=2 loops=1) + Group Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Gather Merge (cost=468828.99..468831.72 rows=20 width=96) (actual time=12730.338..12741.394 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=467828.96..467829.39 rows=10 width=96) (actual time=12708.915..12710.856 rows=2 loops=3) + Group Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Sort (cost=467828.96..467828.99 rows=10 width=112) (actual time=12706.609..12707.021 rows=8085 loops=3) + Sort Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + Sort Method: quicksort Memory: 593kB + Worker 0: Sort Method: quicksort Memory: 620kB + Worker 1: Sort Method: quicksort Memory: 852kB + -> Hash Join (cost=44452.70..467828.80 rows=10 width=112) (actual time=181.852..12699.475 rows=8085 loops=3) + Hash Cond: (supplier.s_nationkey = nation_2.n_nationkey) + -> Nested Loop (cost=44438.42..467814.45 rows=10 width=20) (actual time=155.446..12665.364 rows=8085 loops=3) + -> Nested Loop (cost=44438.13..467763.41 rows=10 width=20) (actual time=155.406..12602.772 rows=8085 loops=3) + -> Nested Loop (cost=44437.70..460838.89 rows=1315 width=24) (actual time=152.275..5718.117 rows=1212976 loops=3) + -> Parallel Hash Join (cost=44437.14..406215.58 rows=329 width=8) (actual time=152.018..2351.476 rows=303453 loops=3) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Parallel Seq Scan on orders (cost=0.00..361542.73 rows=62491 width=12) (actual time=0.045..1612.430 rows=1519171 loops=3) + Filter: (EXTRACT(year FROM (o_orderdate)::timestamp without time zone) = ANY ('{1995,1996}'::numeric[])) + Rows Removed by Filter: 3480829 + -> Parallel Hash (cost=44396.01..44396.01 rows=3290 width=4) (actual time=151.743..151.747 rows=99812 loops=3) + Buckets: 524288 (originally 8192) Batches: 1 (originally 1) Memory Usage: 19904kB + -> Hash Join (cost=24.81..44396.01 rows=3290 width=4) (actual time=0.160..122.858 rows=99812 loops=3) + Hash Cond: (customer.c_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on customer (cost=0.00..41994.40 rows=625040 width=8) (actual time=0.018..61.611 rows=500000 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=4) (actual time=0.129..0.131 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=4) (actual time=0.120..0.127 rows=5 loops=3) + Hash Cond: (nation.n_regionkey = region.r_regionkey) + -> Seq Scan on nation (cost=0.00..11.90 rows=190 width=8) (actual time=0.003..0.005 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.098..0.099 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region (cost=0.00..12.38 rows=1 width=4) (actual time=0.093..0.094 rows=1 loops=3) + Filter: ((r_name)::text = 'AMERICA'::text) + Rows Removed by Filter: 4 + -> Index Scan using lineitem_pkey on lineitem (cost=0.56..164.68 rows=135 width=24) (actual time=0.009..0.010 rows=4 loops=910360) + Index Cond: (l_orderkey = orders.o_orderkey) + -> Index Scan using part_pkey on part (cost=0.43..5.27 rows=1 width=4) (actual time=0.005..0.005 rows=0 loops=3638929) + Index Cond: (p_partkey = lineitem.l_partkey) + Filter: ((p_type)::text = 'ECONOMY ANODIZED STEEL'::text) + Rows Removed by Filter: 1 + -> Index Scan using supplier_pkey on supplier (cost=0.29..5.10 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=24254) + Index Cond: (s_suppkey = lineitem.l_suppkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=26.230..26.231 rows=25 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation nation_2 (cost=0.00..11.90 rows=190 width=72) (actual time=26.206..26.210 rows=25 loops=3) +Planning Time: 3.743 ms +JIT: + Functions: 180 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 9.808 ms, Inlining 0.000 ms, Optimization 2.976 ms, Emission 75.808 ms, Total 88.592 ms +Execution Time: 12743.523 ms",SUCCESS +8,9,TPCH,Q9,"SELECT + nation, + o_year, + SUM(amount) AS sum_profit +FROM ( + SELECT + n.n_name AS nation, + EXTRACT(YEAR FROM o.o_orderdate) AS o_year, + l.l_extendedprice * (1 - l.l_discount) + - ps.ps_supplycost * l.l_quantity AS amount + FROM + tpch.part p + JOIN tpch.lineitem l + ON p.p_partkey = l.l_partkey + JOIN tpch.partsupp ps + ON ps.ps_partkey = l.l_partkey + AND ps.ps_suppkey = l.l_suppkey + JOIN tpch.supplier s + ON s.s_suppkey = l.l_suppkey + JOIN tpch.orders o + ON o.o_orderkey = l.l_orderkey + JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey + WHERE + p.p_name LIKE '%green%' +) AS profit +GROUP BY + nation, + o_year +ORDER BY + nation, + o_year DESC;","result = ( + lines.WHERE(CONTAINS(part.name, 'green')) + .CALCULATE( + nation_name=supplier.nation.name, + o_year=YEAR(order.order_date), + value=extended_price * (1 - discount) + - part_and_supplier.supply_cost * quantity, + ).PARTITION(name='groups', by=(nation_name, o_year)) + .CALCULATE(NATION=nation_name, O_YEAR=o_year, sum_profit=SUM(lines.value)) + .ORDER_BY(NATION.ASC(), O_YEAR.DESC()) +)","SELECT + nation.n_name AS NATION, + EXTRACT(YEAR FROM CAST(orders.o_orderdate AS TIMESTAMP)) AS O_YEAR, + COALESCE( + SUM( + lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + ) - partsupp.ps_supplycost * lineitem.l_quantity + ), + 0 + ) AS sum_profit +FROM tpch.lineitem AS lineitem +JOIN tpch.part AS part + ON lineitem.l_partkey = part.p_partkey AND part.p_name LIKE '%green%' +JOIN tpch.supplier AS supplier + ON lineitem.l_suppkey = supplier.s_suppkey +JOIN tpch.nation AS nation + ON nation.n_nationkey = supplier.s_nationkey +JOIN tpch.orders AS orders + ON lineitem.l_orderkey = orders.o_orderkey +JOIN tpch.partsupp AS partsupp + ON lineitem.l_partkey = partsupp.ps_partkey + AND lineitem.l_suppkey = partsupp.ps_suppkey +GROUP BY + 1, + 2 +ORDER BY + 1 NULLS FIRST, + 2 DESC NULLS LAST",21.14323279600012,22.865245553000022,"Finalize GroupAggregate (cost=1662505.45..1662517.99 rows=93 width=132) (actual time=21618.686..22259.384 rows=175 loops=1) + Group Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) + -> Gather Merge (cost=1662505.45..1662515.81 rows=78 width=132) (actual time=21615.079..22259.047 rows=525 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1661505.42..1661506.79 rows=39 width=132) (actual time=20888.659..21563.905 rows=175 loops=3) + Group Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) + -> Sort (cost=1661505.42..1661505.52 rows=39 width=123) (actual time=20885.779..21074.023 rows=1087204 loops=3) + Sort Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) DESC + Sort Method: external merge Disk: 44968kB + Worker 0: Sort Method: external merge Disk: 65144kB + Worker 1: Sort Method: external merge Disk: 44888kB + -> Hash Join (cost=322725.34..1661504.39 rows=39 width=123) (actual time=9191.664..19518.181 rows=1087204 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Nested Loop (cost=322711.06..1661489.92 rows=39 width=31) (actual time=8836.581..18740.181 rows=1087204 loops=3) + -> Nested Loop (cost=322710.62..1661269.77 rows=39 width=31) (actual time=8836.483..12312.733 rows=1087204 loops=3) + -> Parallel Hash Join (cost=322710.33..1661058.58 rows=39 width=35) (actual time=8836.423..9756.008 rows=1087204 loops=3) + Hash Cond: ((p.p_partkey = ps.ps_partkey) AND (l.l_suppkey = ps.ps_suppkey)) + -> Parallel Hash Join (cost=48032.14..1349019.24 rows=1009933 width=33) (actual time=130.436..6240.128 rows=1087204 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235373.20 rows=24995720 width=29) (actual time=0.022..3319.480 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.31..47611.31 rows=33666 width=4) (actual time=130.210..130.211 rows=36261 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5344kB + -> Parallel Seq Scan on part p (cost=0.00..47611.31 rows=33666 width=4) (actual time=0.065..119.561 rows=36261 loops=3) + Filter: ((p_name)::text ~~ '%green%'::text) + Rows Removed by Filter: 630406 + -> Parallel Hash (cost=208400.08..208400.08 rows=3333408 width=14) (actual time=2189.773..2189.773 rows=2666667 loops=3) + Buckets: 262144 Batches: 64 Memory Usage: 7968kB + -> Parallel Seq Scan on partsupp ps (cost=0.00..208400.08 rows=3333408 width=14) (actual time=0.197..1576.330 rows=2666667 loops=3) + -> Index Scan using supplier_pkey on supplier s (cost=0.29..5.42 rows=1 width=8) (actual time=0.002..0.002 rows=1 loops=3261613) + Index Cond: (s_suppkey = ps.ps_suppkey) + -> Index Scan using orders_pkey on orders o (cost=0.43..5.64 rows=1 width=8) (actual time=0.006..0.006 rows=1 loops=3261613) + Index Cond: (o_orderkey = l.l_orderkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=355.040..355.041 rows=25 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation n (cost=0.00..11.90 rows=190 width=72) (actual time=355.009..355.016 rows=25 loops=3) +Planning Time: 5.299 ms +JIT: + Functions: 141 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 9.994 ms, Inlining 194.039 ms, Optimization 527.289 ms, Emission 343.908 ms, Total 1075.229 ms +Execution Time: 22266.983 ms","Finalize GroupAggregate (cost=1647379.63..1647393.18 rows=99 width=132) (actual time=23370.346..24392.794 rows=175 loops=1) + Group Key: nation.n_name, (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Gather Merge (cost=1647379.63..1647390.63 rows=82 width=132) (actual time=23360.460..24392.401 rows=525 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1646379.60..1646381.14 rows=41 width=132) (actual time=22819.976..23541.043 rows=175 loops=3) + Group Key: nation.n_name, (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Sort (cost=1646379.60..1646379.70 rows=41 width=123) (actual time=22817.560..23015.821 rows=1087204 loops=3) + Sort Key: nation.n_name NULLS FIRST, (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) DESC NULLS LAST + Sort Method: external merge Disk: 64368kB + Worker 0: Sort Method: external merge Disk: 45352kB + Worker 1: Sort Method: external merge Disk: 45344kB + -> Nested Loop (cost=1372074.23..1646378.50 rows=41 width=123) (actual time=9499.480..21585.381 rows=1087204 loops=3) + -> Hash Join (cost=1372073.80..1646146.86 rows=41 width=95) (actual time=9499.370..13042.513 rows=1087204 loops=3) + Hash Cond: (supplier.s_nationkey = nation.n_nationkey) + -> Nested Loop (cost=1372059.52..1646132.48 rows=41 width=31) (actual time=9085.509..12394.684 rows=1087204 loops=3) + -> Parallel Hash Join (cost=1372059.23..1645905.05 rows=42 width=35) (actual time=9085.446..10391.515 rows=1087204 loops=3) + Hash Cond: ((partsupp.ps_partkey = lineitem.l_partkey) AND (partsupp.ps_suppkey = lineitem.l_suppkey)) + -> Parallel Seq Scan on partsupp (cost=0.00..208400.08 rows=3333408 width=14) (actual time=0.204..1980.798 rows=2666667 loops=3) + -> Parallel Hash (cost=1349019.24..1349019.24 rows=1009933 width=33) (actual time=6531.027..6531.256 rows=1087204 loops=3) + Buckets: 131072 Batches: 32 Memory Usage: 8384kB + -> Parallel Hash Join (cost=48032.14..1349019.24 rows=1009933 width=33) (actual time=115.049..6151.645 rows=1087204 loops=3) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1235373.20 rows=24995720 width=29) (actual time=0.019..3306.803 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.31..47611.31 rows=33666 width=4) (actual time=114.579..114.580 rows=36261 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5312kB + -> Parallel Seq Scan on part (cost=0.00..47611.31 rows=33666 width=4) (actual time=0.047..106.931 rows=36261 loops=3) + Filter: ((p_name)::text ~~ '%green%'::text) + Rows Removed by Filter: 630406 + -> Index Scan using supplier_pkey on supplier (cost=0.29..5.42 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=3261613) + Index Cond: (s_suppkey = lineitem.l_suppkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=413.825..413.825 rows=25 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation (cost=0.00..11.90 rows=190 width=72) (actual time=413.794..413.802 rows=25 loops=3) + -> Index Scan using orders_pkey on orders (cost=0.43..5.64 rows=1 width=8) (actual time=0.007..0.007 rows=1 loops=3261613) + Index Cond: (o_orderkey = lineitem.l_orderkey) +Planning Time: 5.304 ms +JIT: + Functions: 141 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.813 ms, Inlining 199.332 ms, Optimization 613.691 ms, Emission 428.572 ms, Total 1250.407 ms +Execution Time: 24402.927 ms",SUCCESS +9,10,TPCH,Q10,"SELECT + c.c_custkey, + c.c_name, + SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue, + c.c_acctbal, + n.n_name, + c.c_address, + c.c_phone, + c.c_comment +FROM + tpch.customer c +JOIN tpch.orders o + ON c.c_custkey = o.o_custkey +JOIN tpch.lineitem l + ON l.l_orderkey = o.o_orderkey +JOIN tpch.nation n + ON c.c_nationkey = n.n_nationkey +WHERE + o.o_orderdate >= DATE '1993-10-01' + AND o.o_orderdate < DATE '1993-10-01' + INTERVAL '3 months' + AND l.l_returnflag = 'R' +GROUP BY + c.c_custkey, + c.c_name, + c.c_acctbal, + c.c_phone, + n.n_name, + c.c_address, + c.c_comment +ORDER BY + revenue DESC +LIMIT 20;","selected_lines = orders.WHERE( + (YEAR(order_date) == 1993) & (QUARTER(order_date) == 4) +).lines.WHERE(return_flag == ""R"") +result = customers.CALCULATE( + C_CUSTKEY=key, + C_NAME=name, + REVENUE=SUM(selected_lines.extended_price * (1 - selected_lines.discount)), + C_ACCTBAL=account_balance, + N_NAME=nation.name, + C_ADDRESS=address, + C_PHONE=phone, + C_COMMENT=comment, +).TOP_K(20, by=(REVENUE.DESC(), C_CUSTKEY.ASC()))","WITH _s3 AS ( + SELECT + orders.o_custkey, + SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )) AS sum_expr + FROM tpch.orders AS orders + JOIN tpch.lineitem AS lineitem + ON lineitem.l_orderkey = orders.o_orderkey AND lineitem.l_returnflag = 'R' + WHERE + EXTRACT(MONTH FROM CAST(orders.o_orderdate AS TIMESTAMP)) IN (10, 11, 12) + AND EXTRACT(YEAR FROM CAST(orders.o_orderdate AS TIMESTAMP)) = 1993 + GROUP BY + 1 +) +SELECT + customer.c_custkey AS C_CUSTKEY, + customer.c_name AS C_NAME, + COALESCE(_s3.sum_expr, 0) AS REVENUE, + customer.c_acctbal AS C_ACCTBAL, + nation.n_name AS N_NAME, + customer.c_address AS C_ADDRESS, + customer.c_phone AS C_PHONE, + customer.c_comment AS C_COMMENT +FROM tpch.customer AS customer +LEFT JOIN _s3 AS _s3 + ON _s3.o_custkey = customer.c_custkey +JOIN tpch.nation AS nation + ON customer.c_nationkey = nation.n_nationkey +ORDER BY + 3 DESC NULLS LAST, + 1 NULLS FIRST +LIMIT 20",10.72278461299993,7.343343968999989,"Limit (cost=1939262.43..1939262.48 rows=20 width=243) (actual time=8259.452..8412.125 rows=20 loops=1) + -> Sort (cost=1939262.43..1940657.82 rows=558157 width=243) (actual time=8029.844..8182.514 rows=20 loops=1) + Sort Key: (sum((l.l_extendedprice * ('1'::numeric - l.l_discount)))) DESC + Sort Method: top-N heapsort Memory: 34kB + -> Finalize GroupAggregate (cost=1852698.73..1924410.07 rows=558157 width=243) (actual time=7399.700..8087.593 rows=381105 loops=1) + Group Key: c.c_custkey, n.n_name + -> Gather Merge (cost=1852698.73..1912781.81 rows=465130 width=243) (actual time=7399.686..7820.188 rows=382630 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1851698.70..1858094.24 rows=232565 width=243) (actual time=7382.023..7665.124 rows=127543 loops=3) + Group Key: c.c_custkey, n.n_name + -> Sort (cost=1851698.70..1852280.11 rows=232565 width=223) (actual time=7381.976..7434.047 rows=382361 loops=3) + Sort Key: c.c_custkey, n.n_name + Sort Method: external merge Disk: 57808kB + Worker 0: Sort Method: external merge Disk: 57536kB + Worker 1: Sort Method: external merge Disk: 83424kB + -> Hash Join (cost=412975.75..1806325.20 rows=232565 width=223) (actual time=6869.577..7093.752 rows=382361 loops=3) + Hash Cond: (c.c_nationkey = n.n_nationkey) + -> Parallel Hash Join (cost=412961.47..1805686.83 rows=232565 width=159) (actual time=6643.942..6805.538 rows=382361 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Hash Join (cost=349725.07..1726138.94 rows=232565 width=16) (actual time=5639.940..6257.060 rows=382361 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1297862.50 rows=6266427 width=16) (actual time=0.050..4177.677 rows=4936061 loops=3) + Filter: (l_returnflag = 'R'::bpchar) + Rows Removed by Filter: 15059290 + -> Parallel Hash (cost=345920.06..345920.06 rows=231921 width=8) (actual time=518.300..518.301 rows=191052 loops=3) + Buckets: 262144 Batches: 4 Memory Usage: 7680kB + -> Parallel Seq Scan on orders o (cost=0.00..345920.06 rows=231921 width=8) (actual time=0.051..474.544 rows=191052 loops=3) + Filter: ((o_orderdate >= '1993-10-01'::date) AND (o_orderdate < '1994-01-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 4808948 + -> Parallel Hash (cost=41994.40..41994.40 rows=625040 width=147) (actual time=302.648..302.649 rows=500000 loops=3) + Buckets: 65536 Batches: 64 Memory Usage: 4832kB + -> Parallel Seq Scan on customer c (cost=0.00..41994.40 rows=625040 width=147) (actual time=0.038..88.696 rows=500000 loops=3) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=225.601..225.601 rows=25 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation n (cost=0.00..11.90 rows=190 width=72) (actual time=225.577..225.582 rows=25 loops=3) +Planning Time: 0.480 ms +JIT: + Functions: 109 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.295 ms, Inlining 171.476 ms, Optimization 440.359 ms, Emission 294.854 ms, Total 911.984 ms +Execution Time: 8421.298 ms","Limit (cost=625688.59..625688.64 rows=20 width=243) (actual time=7784.034..7784.137 rows=20 loops=1) + -> Sort (cost=625688.59..629438.83 rows=1500097 width=243) (actual time=7579.000..7579.102 rows=20 loops=1) + Sort Key: (COALESCE(_s3.sum_expr, '0'::numeric)) DESC NULLS LAST, customer.c_custkey NULLS FIRST + Sort Method: top-N heapsort Memory: 30kB + -> Hash Join (cost=527063.23..585771.55 rows=1500097 width=243) (actual time=6104.376..7241.060 rows=1500000 loops=1) + Hash Cond: (customer.c_nationkey = nation.n_nationkey) + -> Hash Left Join (cost=527048.95..581731.69 rows=1500097 width=179) (actual time=6104.123..7029.107 rows=1500000 loops=1) + Hash Cond: (customer.c_custkey = _s3.o_custkey) + -> Seq Scan on customer (cost=0.00..50744.97 rows=1500097 width=147) (actual time=0.009..155.535 rows=1500000 loops=1) + -> Hash (cost=527034.90..527034.90 rows=1124 width=36) (actual time=6103.986..6104.084 rows=381105 loops=1) + Buckets: 262144 (originally 2048) Batches: 4 (originally 1) Memory Usage: 6514kB + -> Subquery Scan on _s3 (cost=526882.31..527034.90 rows=1124 width=36) (actual time=5402.430..6031.852 rows=381105 loops=1) + -> Finalize GroupAggregate (cost=526882.31..527023.66 rows=1124 width=36) (actual time=5402.427..6002.382 rows=381105 loops=1) + Group Key: orders.o_custkey + -> Gather Merge (cost=526882.31..527002.56 rows=940 width=36) (actual time=5402.415..5741.916 rows=449695 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=525882.29..525894.04 rows=470 width=36) (actual time=5377.084..5624.736 rows=149898 loops=3) + Group Key: orders.o_custkey + -> Sort (cost=525882.29..525883.46 rows=470 width=16) (actual time=5377.048..5421.730 rows=382361 loops=3) + Sort Key: orders.o_custkey + Sort Method: external merge Disk: 12376kB + Worker 0: Sort Method: external merge Disk: 8952kB + Worker 1: Sort Method: external merge Disk: 9624kB + -> Nested Loop (cost=0.56..525861.43 rows=470 width=16) (actual time=165.605..5239.849 rows=382361 loops=3) + -> Parallel Seq Scan on orders (cost=0.00..416222.10 rows=469 width=8) (actual time=165.393..1522.707 rows=191052 loops=3) + Filter: ((EXTRACT(year FROM (o_orderdate)::timestamp without time zone) = '1993'::numeric) AND (EXTRACT(month FROM (o_orderdate)::timestamp without time zone) = ANY ('{10,11,12}'::numeric[]))) + Rows Removed by Filter: 4808948 + -> Index Scan using lineitem_pkey on lineitem (cost=0.56..233.43 rows=34 width=16) (actual time=0.018..0.019 rows=2 loops=573157) + Index Cond: (l_orderkey = orders.o_orderkey) + Filter: (l_returnflag = 'R'::bpchar) + Rows Removed by Filter: 2 + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=0.240..0.240 rows=25 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on nation (cost=0.00..11.90 rows=190 width=72) (actual time=0.229..0.231 rows=25 loops=1) +Planning Time: 1.684 ms +JIT: + Functions: 67 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.138 ms, Inlining 195.272 ms, Optimization 297.990 ms, Emission 208.008 ms, Total 709.409 ms +Execution Time: 7787.278 ms",SUCCESS +10,11,TPCH,Q11,"SELECT + ps.ps_partkey, + SUM(ps.ps_supplycost * ps.ps_availqty) AS value +FROM + tpch.partsupp ps +JOIN tpch.supplier s + ON ps.ps_suppkey = s.s_suppkey +JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey +WHERE + n.n_name = 'GERMANY' +GROUP BY + ps.ps_partkey +HAVING + SUM(ps.ps_supplycost * ps.ps_availqty) > ( + SELECT + SUM(ps2.ps_supplycost * ps2.ps_availqty) * 0.0001 + FROM + tpch.partsupp ps2 + JOIN tpch.supplier s2 + ON ps2.ps_suppkey = s2.s_suppkey + JOIN tpch.nation n2 + ON s2.s_nationkey = n2.n_nationkey + WHERE + n2.n_name = 'GERMANY' + ) +ORDER BY + value DESC;","is_german_supplier = supplier.nation.name == ""GERMANY"" +selected_records = supply_records.WHERE(is_german_supplier).CALCULATE( + metric=supply_cost * available_quantity +) +result = ( + TPCH.CALCULATE(min_market_share=SUM(selected_records.metric) * 0.0001) + .supply_records.WHERE(is_german_supplier) + .PARTITION(name=""parts"", by=part_key) + .CALCULATE( + PS_PARTKEY=part_key, + VALUE=SUM(supply_records.supply_cost * supply_records.available_quantity), + ) + .WHERE(VALUE > min_market_share) + .TOP_K(10, by=VALUE.DESC()) +)","WITH _s0 AS ( + SELECT + s_nationkey, + s_suppkey + FROM tpch.supplier +), _t2 AS ( + SELECT + n_name, + n_nationkey + FROM tpch.nation + WHERE + n_name = 'GERMANY' +), _s8 AS ( + SELECT + SUM(partsupp.ps_supplycost * partsupp.ps_availqty) AS sum_metric + FROM tpch.partsupp AS partsupp + JOIN _s0 AS _s0 + ON _s0.s_suppkey = partsupp.ps_suppkey + JOIN _t2 AS _t2 + ON _s0.s_nationkey = _t2.n_nationkey +), _s9 AS ( + SELECT + partsupp.ps_partkey, + SUM(partsupp.ps_supplycost * partsupp.ps_availqty) AS sum_expr + FROM tpch.partsupp AS partsupp + JOIN _s0 AS _s4 + ON _s4.s_suppkey = partsupp.ps_suppkey + JOIN _t2 AS _t4 + ON _s4.s_nationkey = _t4.n_nationkey + GROUP BY + 1 +) +SELECT + _s9.ps_partkey AS PS_PARTKEY, + COALESCE(_s9.sum_expr, 0) AS VALUE +FROM _s8 AS _s8 +JOIN _s9 AS _s9 + ON ( + COALESCE(_s8.sum_metric, 0) * 0.0001 + ) < COALESCE(_s9.sum_expr, 0) +ORDER BY + 2 DESC NULLS LAST +LIMIT 10",3.1100652770001034,7.639850938000109,"Sort (cost=457413.44..457448.06 rows=13848 width=36) (actual time=1726.431..1730.114 rows=0 loops=1) + Sort Key: (sum((ps.ps_supplycost * (ps.ps_availqty)::numeric))) DESC + Sort Method: quicksort Memory: 25kB + InitPlan 1 (returns $1) + -> Finalize Aggregate (cost=225030.38..225030.39 rows=1 width=32) (actual time=692.770..693.098 rows=1 loops=1) + -> Gather (cost=225030.16..225030.37 rows=2 width=32) (actual time=692.587..693.079 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=224030.16..224030.17 rows=1 width=32) (actual time=676.845..676.848 rows=1 loops=3) + -> Parallel Hash Join (cost=2898.35..223900.33 rows=17310 width=10) (actual time=13.601..642.973 rows=107973 loops=3) + Hash Cond: (ps2.ps_suppkey = s2.s_suppkey) + -> Parallel Seq Scan on partsupp ps2 (cost=0.00..208400.08 rows=3333408 width=14) (actual time=0.020..306.143 rows=2666667 loops=3) + -> Parallel Hash (cost=2894.48..2894.48 rows=309 width=4) (actual time=6.561..6.562 rows=1350 loops=3) + Buckets: 4096 (originally 1024) Batches: 1 (originally 1) Memory Usage: 216kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=4) (actual time=0.052..18.891 rows=4049 loops=1) + Hash Cond: (s2.s_nationkey = n2.n_nationkey) + -> Parallel Seq Scan on supplier s2 (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.005..7.233 rows=100000 loops=1) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.025..0.027 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n2 (cost=0.00..12.38 rows=1 width=4) (actual time=0.018..0.020 rows=1 loops=1) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 + -> Finalize GroupAggregate (cost=226118.92..231430.49 rows=13848 width=36) (actual time=1726.427..1729.782 rows=0 loops=1) + Group Key: ps.ps_partkey + Filter: (sum((ps.ps_supplycost * (ps.ps_availqty)::numeric)) > $1) + Rows Removed by Filter: 304774 + -> Gather Merge (cost=226118.92..230547.68 rows=34620 width=36) (actual time=703.864..836.258 rows=304794 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=225118.90..225551.65 rows=17310 width=36) (actual time=686.050..782.161 rows=101598 loops=3) + Group Key: ps.ps_partkey + -> Sort (cost=225118.90..225162.17 rows=17310 width=14) (actual time=686.011..696.327 rows=107973 loops=3) + Sort Key: ps.ps_partkey + Sort Method: external merge Disk: 2768kB + Worker 0: Sort Method: external merge Disk: 3080kB + Worker 1: Sort Method: external merge Disk: 2416kB + -> Parallel Hash Join (cost=2898.35..223900.33 rows=17310 width=14) (actual time=24.872..655.176 rows=107973 loops=3) + Hash Cond: (ps.ps_suppkey = s.s_suppkey) + -> Parallel Seq Scan on partsupp ps (cost=0.00..208400.08 rows=3333408 width=18) (actual time=0.030..304.006 rows=2666667 loops=3) + -> Parallel Hash (cost=2894.48..2894.48 rows=309 width=4) (actual time=24.562..24.565 rows=1350 loops=3) + Buckets: 4096 (originally 1024) Batches: 1 (originally 1) Memory Usage: 248kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=4) (actual time=14.488..20.246 rows=1350 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.007..2.705 rows=33333 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=14.457..14.458 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n (cost=0.00..12.38 rows=1 width=4) (actual time=14.447..14.450 rows=1 loops=3) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 +Planning Time: 0.369 ms +JIT: + Functions: 147 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 6.235 ms, Inlining 0.000 ms, Optimization 2.912 ms, Emission 60.767 ms, Total 69.913 ms +Execution Time: 1732.278 ms","Limit (cost=896001.01..896001.04 rows=10 width=36) (actual time=7569.058..7569.066 rows=0 loops=1) + CTE _s0 + -> Seq Scan on supplier (cost=0.00..3136.00 rows=100000 width=8) (actual time=0.017..8.472 rows=100000 loops=1) + CTE _t2 + -> Seq Scan on nation (cost=0.00..12.38 rows=1 width=72) (actual time=0.010..0.011 rows=1 loops=1) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 + -> Sort (cost=892852.64..892885.53 rows=13156 width=36) (actual time=7360.500..7360.507 rows=0 loops=1) + Sort Key: (COALESCE((sum((partsupp_1.ps_supplycost * (partsupp_1.ps_availqty)::numeric))), '0'::numeric)) DESC NULLS LAST + Sort Method: quicksort Memory: 25kB + -> Nested Loop (cost=890989.65..892568.34 rows=13156 width=36) (actual time=7360.490..7360.496 rows=0 loops=1) + Join Filter: ((COALESCE((sum((partsupp.ps_supplycost * (partsupp.ps_availqty)::numeric))), '0'::numeric) * 0.0001) < COALESCE((sum((partsupp_1.ps_supplycost * (partsupp_1.ps_availqty)::numeric))), '0'::numeric)) + Rows Removed by Join Filter: 304774 + -> Aggregate (cost=436323.34..436323.35 rows=1 width=32) (actual time=3742.696..3742.700 rows=1 loops=1) + -> Hash Join (cost=394134.04..436027.33 rows=39467 width=10) (actual time=2928.857..3684.043 rows=323920 loops=1) + Hash Cond: (_s0.s_suppkey = partsupp.ps_suppkey) + -> Hash Join (cost=0.03..2380.03 rows=500 width=4) (actual time=0.060..35.317 rows=4049 loops=1) + Hash Cond: (_s0.s_nationkey = _t2.n_nationkey) + -> CTE Scan on _s0 (cost=0.00..2000.00 rows=100000 width=8) (actual time=0.020..28.034 rows=100000 loops=1) + -> Hash (cost=0.02..0.02 rows=1 width=4) (actual time=0.018..0.019 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> CTE Scan on _t2 (cost=0.00..0.02 rows=1 width=4) (actual time=0.013..0.015 rows=1 loops=1) + -> Hash (cost=255067.78..255067.78 rows=8000178 width=14) (actual time=2926.169..2926.169 rows=8000000 loops=1) + Buckets: 262144 (originally 262144) Batches: 128 (originally 64) Memory Usage: 8116kB + -> Seq Scan on partsupp (cost=0.00..255067.78 rows=8000178 width=14) (actual time=0.036..1719.177 rows=8000000 loops=1) + -> GroupAggregate (cost=454666.31..455652.99 rows=39467 width=36) (actual time=3388.890..3576.500 rows=304774 loops=1) + Group Key: partsupp_1.ps_partkey + -> Sort (cost=454666.31..454764.98 rows=39467 width=14) (actual time=3388.851..3410.514 rows=323920 loops=1) + Sort Key: partsupp_1.ps_partkey + Sort Method: external sort Disk: 9544kB + -> Hash Join (cost=401947.04..451653.33 rows=39467 width=14) (actual time=2824.352..3280.281 rows=323920 loops=1) + Hash Cond: (_s4.s_suppkey = partsupp_1.ps_suppkey) + -> Hash Join (cost=0.03..2380.03 rows=500 width=4) (actual time=0.044..12.655 rows=4049 loops=1) + Hash Cond: (_s4.s_nationkey = _t4.n_nationkey) + -> CTE Scan on _s0 _s4 (cost=0.00..2000.00 rows=100000 width=8) (actual time=0.017..6.723 rows=100000 loops=1) + -> Hash (cost=0.02..0.02 rows=1 width=4) (actual time=0.010..0.011 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> CTE Scan on _t2 _t4 (cost=0.00..0.02 rows=1 width=4) (actual time=0.005..0.006 rows=1 loops=1) + -> Hash (cost=255067.78..255067.78 rows=8000178 width=18) (actual time=2823.154..2823.154 rows=8000000 loops=1) + Buckets: 131072 Batches: 64 Memory Usage: 7403kB + -> Seq Scan on partsupp partsupp_1 (cost=0.00..255067.78 rows=8000178 width=18) (actual time=0.021..1638.545 rows=8000000 loops=1) +Planning Time: 0.278 ms +JIT: + Functions: 52 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.366 ms, Inlining 10.581 ms, Optimization 116.950 ms, Emission 81.162 ms, Total 212.059 ms +Execution Time: 7574.986 ms",SUCCESS +11,12,TPCH,Q12,"SELECT + l.l_shipmode, + SUM( + CASE + WHEN o.o_orderpriority = '1-URGENT' + OR o.o_orderpriority = '2-HIGH' + THEN 1 + ELSE 0 + END + ) AS high_line_count, + SUM( + CASE + WHEN o.o_orderpriority <> '1-URGENT' + AND o.o_orderpriority <> '2-HIGH' + THEN 1 + ELSE 0 + END + ) AS low_line_count +FROM + tpch.orders o +JOIN tpch.lineitem l + ON o.o_orderkey = l.l_orderkey +WHERE + l.l_shipmode IN ('MAIL', 'SHIP') + AND l.l_commitdate < l.l_receiptdate + AND l.l_shipdate < l.l_commitdate + AND l.l_receiptdate >= DATE '1994-01-01' + AND l.l_receiptdate < DATE '1994-01-01' + INTERVAL '1 year' +GROUP BY + l.l_shipmode +ORDER BY + l.l_shipmode;","result = ( + lines.WHERE( + ((ship_mode == ""MAIL"") | (ship_mode == ""SHIP"")) + & (ship_date < commit_date) + & (commit_date < receipt_date) + & (YEAR(receipt_date) == 1994) + ) + .CALCULATE( + is_high_priority=ISIN(order.order_priority, (""1-URGENT"", ""2-HIGH"")), + ) + .PARTITION(""modes"", by=ship_mode) + .CALCULATE( + L_SHIPMODE=ship_mode, + HIGH_LINE_COUNT=SUM(lines.is_high_priority), + LOW_LINE_COUNT=SUM(~(lines.is_high_priority)), + ) + .ORDER_BY(L_SHIPMODE.ASC()) + )","SELECT + lineitem.l_shipmode AS L_SHIPMODE, + COALESCE( + SUM(CASE WHEN orders.o_orderpriority IN ('1-URGENT', '2-HIGH') THEN 1 ELSE 0 END), + 0 + ) AS HIGH_LINE_COUNT, + COALESCE( + SUM(CASE WHEN NOT orders.o_orderpriority IN ('1-URGENT', '2-HIGH') THEN 1 ELSE 0 END), + 0 + ) AS LOW_LINE_COUNT +FROM tpch.lineitem AS lineitem +JOIN tpch.orders AS orders + ON lineitem.l_orderkey = orders.o_orderkey +WHERE + EXTRACT(YEAR FROM CAST(lineitem.l_receiptdate AS TIMESTAMP)) = 1994 + AND lineitem.l_commitdate < lineitem.l_receiptdate + AND lineitem.l_commitdate > lineitem.l_shipdate + AND ( + lineitem.l_shipmode = 'MAIL' OR lineitem.l_shipmode = 'SHIP' + ) +GROUP BY + 1 +ORDER BY + 1 NULLS FIRST",8.079591035000021,5.093245161999903,"Finalize GroupAggregate (cost=2016482.59..2018914.41 rows=7 width=21) (actual time=9584.225..9616.542 rows=2 loops=1) + Group Key: l.l_shipmode + -> Gather Merge (cost=2016482.59..2018914.24 rows=14 width=21) (actual time=9567.158..9616.496 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=2015482.57..2017912.60 rows=7 width=21) (actual time=9536.022..9552.401 rows=2 loops=3) + Group Key: l.l_shipmode + -> Sort (cost=2015482.57..2015786.31 rows=121498 width=14) (actual time=9520.673..9532.095 rows=103601 loops=3) + Sort Key: l.l_shipmode + Sort Method: external merge Disk: 2728kB + Worker 0: Sort Method: external merge Disk: 2360kB + Worker 1: Sort Method: external merge Disk: 2352kB + -> Parallel Hash Join (cost=423302.08..2003142.71 rows=121498 width=14) (actual time=8282.185..9500.019 rows=103601 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1547819.70 rows=121498 width=9) (actual time=0.116..6347.831 rows=103601 loops=3) + Filter: (((l_shipmode)::text = ANY ('{MAIL,SHIP}'::text[])) AND (l_commitdate < l_receiptdate) AND (l_shipdate < l_commitdate) AND (l_receiptdate >= '1994-01-01'::date) AND (l_receiptdate < '1995-01-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 19891750 + -> Parallel Hash (cost=314674.70..314674.70 rows=6249070 width=13) (actual time=1872.405..1872.405 rows=5000000 loops=3) + Buckets: 262144 Batches: 128 Memory Usage: 7808kB + -> Parallel Seq Scan on orders o (cost=0.00..314674.70 rows=6249070 width=13) (actual time=227.242..881.644 rows=5000000 loops=3) +Planning Time: 0.236 ms +JIT: + Functions: 54 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.537 ms, Inlining 174.797 ms, Optimization 296.624 ms, Emission 210.511 ms, Total 685.469 ms +Execution Time: 9618.134 ms","Finalize GroupAggregate (cost=1703487.71..1703544.86 rows=7 width=21) (actual time=5030.022..5030.133 rows=2 loops=1) + Group Key: lineitem.l_shipmode + -> Gather Merge (cost=1703487.71..1703544.68 rows=14 width=21) (actual time=5019.309..5030.096 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1702487.68..1702543.04 rows=7 width=21) (actual time=4980.945..4992.504 rows=2 loops=3) + Group Key: lineitem.l_shipmode + -> Sort (cost=1702487.68..1702496.90 rows=3686 width=14) (actual time=4963.501..4972.453 rows=103601 loops=3) + Sort Key: lineitem.l_shipmode NULLS FIRST + Sort Method: external merge Disk: 2288kB + Worker 0: Sort Method: external merge Disk: 2184kB + Worker 1: Sort Method: external merge Disk: 2968kB + -> Nested Loop (cost=0.43..1702269.33 rows=3686 width=14) (actual time=256.201..4929.004 rows=103601 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1672798.30 rows=3686 width=9) (actual time=256.053..4467.046 rows=103601 loops=3) + Filter: ((l_commitdate < l_receiptdate) AND (l_commitdate > l_shipdate) AND (((l_shipmode)::text = 'MAIL'::text) OR ((l_shipmode)::text = 'SHIP'::text)) AND (EXTRACT(year FROM (l_receiptdate)::timestamp without time zone) = '1994'::numeric)) + Rows Removed by Filter: 19891750 + -> Index Scan using orders_pkey on orders (cost=0.43..8.00 rows=1 width=13) (actual time=0.004..0.004 rows=1 loops=310803) + Index Cond: (o_orderkey = lineitem.l_orderkey) +Planning Time: 1.953 ms +JIT: + Functions: 42 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.973 ms, Inlining 186.078 ms, Optimization 340.562 ms, Emission 241.462 ms, Total 774.076 ms +Execution Time: 5031.589 ms",SUCCESS +12,13,TPCH,Q13,"SELECT + c_count, + COUNT(*) AS custdist +FROM ( + SELECT + c.c_custkey, + COUNT(o.o_orderkey) AS c_count + FROM + tpch.customer c + LEFT JOIN tpch.orders o + ON c.c_custkey = o.o_custkey + AND o.o_comment NOT LIKE '%special%requests%' + GROUP BY + c.c_custkey +) AS c_orders +GROUP BY + c_count +ORDER BY + custdist DESC, + c_count DESC +LIMIT 10;","selected_orders = orders.WHERE(~(LIKE(comment, ""%special%requests%""))) +result = ( + customers.CALCULATE(num_non_special_orders=COUNT(selected_orders)) + .PARTITION(name=""num_order_groups"", by=num_non_special_orders) + .CALCULATE(C_COUNT=num_non_special_orders, CUSTDIST=COUNT(customers)) + .TOP_K(10, by=(CUSTDIST.DESC(), C_COUNT.DESC())) +)","WITH _s1 AS ( + SELECT + o_custkey, + COUNT(*) AS n_rows + FROM tpch.orders + WHERE + NOT o_comment LIKE '%special%requests%' + GROUP BY + 1 +) +SELECT + COALESCE(_s1.n_rows, 0) AS C_COUNT, + COUNT(*) AS CUSTDIST +FROM tpch.customer AS customer +LEFT JOIN _s1 AS _s1 + ON _s1.o_custkey = customer.c_custkey +GROUP BY + 1 +ORDER BY + 2 DESC NULLS LAST, + 1 DESC NULLS LAST +LIMIT 10",6.812726343999884,5.255456644999867,"Limit (cost=1409099.96..1409099.99 rows=10 width=16) (actual time=7085.710..7153.940 rows=10 loops=1) + -> Sort (cost=1409099.96..1409100.46 rows=200 width=16) (actual time=6998.472..7066.700 rows=10 loops=1) + Sort Key: (count(*)) DESC, (count(o.o_orderkey)) DESC + Sort Method: top-N heapsort Memory: 25kB + -> HashAggregate (cost=1409093.64..1409095.64 rows=200 width=16) (actual time=6998.220..7066.453 rows=46 loops=1) + Group Key: count(o.o_orderkey) + Batches: 1 Memory Usage: 40kB + -> Finalize HashAggregate (cost=1342292.45..1386592.19 rows=1500097 width=12) (actual time=6459.543..6928.341 rows=1500000 loops=1) + Group Key: c.c_custkey + Planned Partitions: 32 Batches: 33 Memory Usage: 8209kB Disk Usage: 63216kB + -> Gather (cost=786744.43..1150092.52 rows=3000194 width=12) (actual time=5310.705..6186.388 rows=1628751 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=785744.43..849073.12 rows=1500097 width=12) (actual time=5300.724..5988.123 rows=542917 loops=3) + Group Key: c.c_custkey + Planned Partitions: 32 Batches: 33 Memory Usage: 8209kB Disk Usage: 96000kB + Worker 0: Batches: 33 Memory Usage: 8209kB Disk Usage: 115720kB + Worker 1: Batches: 33 Memory Usage: 8209kB Disk Usage: 161472kB + -> Parallel Hash Right Join (cost=40479.32..437784.86 rows=6185948 width=8) (actual time=2589.166..4038.702 rows=5112535 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..330297.38 rows=6185948 width=8) (actual time=0.060..1569.649 rows=4945861 loops=3) + Filter: ((o_comment)::text !~~ '%special%requests%'::text) + Rows Removed by Filter: 54139 + -> Parallel Hash (cost=30224.32..30224.32 rows=625040 width=4) (actual time=213.404..213.406 rows=500000 loops=3) + Buckets: 262144 Batches: 16 Memory Usage: 5760kB + -> Parallel Index Only Scan using customer_pkey on customer c (cost=0.43..30224.32 rows=625040 width=4) (actual time=0.025..57.655 rows=500000 loops=3) + Heap Fetches: 0 +Planning Time: 2.809 ms +JIT: + Functions: 63 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.425 ms, Inlining 166.012 ms, Optimization 159.161 ms, Emission 118.422 ms, Total 447.020 ms +Execution Time: 7177.595 ms","Limit (cost=1120183.59..1120183.62 rows=10 width=16) (actual time=5943.385..5979.944 rows=10 loops=1) + -> Sort (cost=1120183.59..1120184.09 rows=200 width=16) (actual time=5873.158..5909.715 rows=10 loops=1) + Sort Key: (count(*)) DESC NULLS LAST, (COALESCE((count(*)), '0'::bigint)) DESC NULLS LAST + Sort Method: top-N heapsort Memory: 25kB + -> HashAggregate (cost=1120177.27..1120179.27 rows=200 width=16) (actual time=5873.130..5909.694 rows=46 loops=1) + Group Key: COALESCE((count(*)), '0'::bigint) + Batches: 1 Memory Usage: 40kB + -> Merge Left Join (cost=834701.73..1112676.79 rows=1500097 width=8) (actual time=4581.595..5750.645 rows=1500000 loops=1) + Merge Cond: (customer.c_custkey = orders.o_custkey) + -> Index Only Scan using customer_pkey on customer (cost=0.43..38974.88 rows=1500097 width=4) (actual time=0.022..134.065 rows=1500000 loops=1) + Heap Fetches: 0 + -> Finalize GroupAggregate (cost=834701.31..1050763.19 rows=852821 width=12) (actual time=4581.561..5383.241 rows=999979 loops=1) + Group Key: orders.o_custkey + -> Gather Merge (cost=834701.31..1033706.77 rows=1705642 width=12) (actual time=4581.525..5030.638 rows=2926029 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=833701.28..835833.34 rows=852821 width=12) (actual time=4504.129..4589.567 rows=975343 loops=3) + Sort Key: orders.o_custkey + Sort Method: external merge Disk: 24680kB + Worker 0: Sort Method: external merge Disk: 24568kB + Worker 1: Sort Method: external merge Disk: 25328kB + -> Partial HashAggregate (cost=678256.96..735112.88 rows=852821 width=12) (actual time=3222.133..4137.737 rows=975343 loops=3) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 17 Memory Usage: 8337kB Disk Usage: 129248kB + Worker 0: Batches: 17 Memory Usage: 8337kB Disk Usage: 118792kB + Worker 1: Batches: 17 Memory Usage: 8337kB Disk Usage: 194872kB + -> Parallel Seq Scan on orders (cost=0.00..330297.38 rows=6185948 width=4) (actual time=77.787..1644.753 rows=4945861 loops=3) + Filter: ((o_comment)::text !~~ '%special%requests%'::text) + Rows Removed by Filter: 54139 +Planning Time: 0.170 ms +JIT: + Functions: 38 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.338 ms, Inlining 152.038 ms, Optimization 105.383 ms, Emission 89.926 ms, Total 349.685 ms +Execution Time: 6000.733 ms",SUCCESS +13,14,TPCH,Q14,"SELECT + 100.00 * SUM( + CASE + WHEN p.p_type LIKE 'PROMO%' + THEN l.l_extendedprice * (1 - l.l_discount) + ELSE 0 + END + ) / SUM(l.l_extendedprice * (1 - l.l_discount)) AS promo_revenue +FROM + tpch.lineitem l +JOIN tpch.part p + ON l.l_partkey = p.p_partkey +WHERE + l.l_shipdate >= DATE '1995-09-01' + AND l.l_shipdate < DATE '1995-09-01' + INTERVAL '1 month';","value_metric = extended_price * (1 - discount) +selected_lines = lines.WHERE( + (YEAR(ship_date) == 1995) & (MONTH(ship_date) == 9) +).CALCULATE( + value=value_metric, + promo_value=IFF(STARTSWITH(part.part_type, ""PROMO""), value_metric, 0), +) +result = TPCH.CALCULATE( + PROMO_REVENUE=100.0 + * SUM(selected_lines.promo_value) + / SUM(selected_lines.value) +)","SELECT + ( + 100.0 * COALESCE( + SUM( + CASE + WHEN part.p_type LIKE 'PROMO%' + THEN lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + ) + ELSE 0 + END + ), + 0 + ) + ) / COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS PROMO_REVENUE +FROM tpch.lineitem AS lineitem +JOIN tpch.part AS part + ON lineitem.l_partkey = part.p_partkey +WHERE + EXTRACT(MONTH FROM CAST(lineitem.l_shipdate AS TIMESTAMP)) = 9 + AND EXTRACT(YEAR FROM CAST(lineitem.l_shipdate AS TIMESTAMP)) = 1995",4.609152144000063,6.790599230999987,"Finalize Aggregate (cost=1438590.83..1438590.85 rows=1 width=32) (actual time=2733.588..2758.338 rows=1 loops=1) + -> Gather (cost=1438590.60..1438590.81 rows=2 width=64) (actual time=2733.559..2758.314 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1437590.60..1437590.61 rows=1 width=64) (actual time=2718.889..2718.893 rows=1 loops=3) + -> Parallel Hash Join (cost=61639.56..1431793.00 rows=331291 width=33) (actual time=2515.469..2619.549 rows=249741 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1360351.80 rows=331291 width=16) (actual time=0.070..2053.114 rows=249741 loops=3) + Filter: ((l_shipdate >= '1995-09-01'::date) AND (l_shipdate < '1995-10-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 19745610 + -> Parallel Hash (cost=45528.25..45528.25 rows=833225 width=25) (actual time=384.715..384.716 rows=666667 loops=3) + Buckets: 131072 Batches: 32 Memory Usage: 4864kB + -> Parallel Seq Scan on part p (cost=0.00..45528.25 rows=833225 width=25) (actual time=165.401..255.019 rows=666667 loops=3) +Planning Time: 0.175 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.757 ms, Inlining 173.227 ms, Optimization 186.462 ms, Emission 136.638 ms, Total 499.083 ms +Execution Time: 2759.281 ms","Finalize Aggregate (cost=1616249.97..1616249.98 rows=1 width=32) (actual time=6707.542..6719.949 rows=1 loops=1) + -> Gather (cost=1616249.73..1616249.94 rows=2 width=64) (actual time=6707.392..6719.926 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1615249.73..1615249.74 rows=1 width=64) (actual time=6691.101..6691.102 rows=1 loops=3) + -> Nested Loop (cost=0.43..1615238.79 rows=625 width=33) (actual time=188.872..6555.701 rows=249741 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1610309.00 rows=625 width=16) (actual time=188.800..5205.117 rows=249741 loops=3) + Filter: ((EXTRACT(month FROM (l_shipdate)::timestamp without time zone) = '9'::numeric) AND (EXTRACT(year FROM (l_shipdate)::timestamp without time zone) = '1995'::numeric)) + Rows Removed by Filter: 19745610 + -> Index Scan using part_pkey on part (cost=0.43..7.89 rows=1 width=25) (actual time=0.005..0.005 rows=1 loops=749223) + Index Cond: (p_partkey = lineitem.l_partkey) +Planning Time: 0.191 ms +JIT: + Functions: 32 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.763 ms, Inlining 192.994 ms, Optimization 210.709 ms, Emission 162.535 ms, Total 570.002 ms +Execution Time: 6720.879 ms",SUCCESS +14,15,TPCH,Q15,"WITH revenue AS ( + SELECT + l.l_suppkey AS supplier_no, + SUM(l.l_extendedprice * (1 - l.l_discount)) AS total_revenue + FROM + tpch.lineitem l + WHERE + l.l_shipdate >= DATE '1996-01-01' + AND l.l_shipdate < DATE '1996-01-01' + INTERVAL '3 months' + GROUP BY + l.l_suppkey +) +SELECT + s.s_suppkey, + s.s_name, + s.s_address, + s.s_phone, + r.total_revenue +FROM + tpch.supplier s +JOIN revenue r + ON s.s_suppkey = r.supplier_no +WHERE + r.total_revenue = ( + SELECT + MAX(total_revenue) + FROM + revenue + ) +ORDER BY + s.s_suppkey;","selected_lines = lines.WHERE( + (ship_date >= DATETIME('1996-1-1')) + & (ship_date < DATETIME('1996-4-1')) +) +total = SUM(selected_lines.extended_price * (1 - selected_lines.discount)) +result = ( + TPCH.CALCULATE( + max_revenue=MAX( + suppliers.WHERE(HAS(selected_lines)) + .CALCULATE(total_revenue=total) + .total_revenue + ) + ) + .suppliers.WHERE(HAS(selected_lines) & (total == max_revenue)) + .CALCULATE( + S_SUPPKEY=key, + S_NAME=name, + S_ADDRESS=address, + S_PHONE=phone, + TOTAL_REVENUE=total, + ) + .ORDER_BY(S_SUPPKEY.ASC()) +)","WITH _t3 AS ( + SELECT + l_discount, + l_extendedprice, + l_shipdate, + l_suppkey + FROM tpch.lineitem + WHERE + l_shipdate < CAST('1996-04-01' AS DATE) + AND l_shipdate >= CAST('1996-01-01' AS DATE) +), _t1 AS ( + SELECT + SUM(l_extendedprice * ( + 1 - l_discount + )) AS sum_expr + FROM _t3 + GROUP BY + l_suppkey +), _s0 AS ( + SELECT + MAX(COALESCE(sum_expr, 0)) AS max_total_revenue + FROM _t1 +), _s3 AS ( + SELECT + l_suppkey, + SUM(l_extendedprice * ( + 1 - l_discount + )) AS sum_expr + FROM _t3 + GROUP BY + 1 +) +SELECT + supplier.s_suppkey AS S_SUPPKEY, + supplier.s_name AS S_NAME, + supplier.s_address AS S_ADDRESS, + supplier.s_phone AS S_PHONE, + COALESCE(_s3.sum_expr, 0) AS TOTAL_REVENUE +FROM _s0 AS _s0 +CROSS JOIN tpch.supplier AS supplier +JOIN _s3 AS _s3 + ON _s0.max_total_revenue = COALESCE(_s3.sum_expr, 0) + AND _s3.l_suppkey = supplier.s_suppkey +ORDER BY + 1 NULLS FIRST",3.5497031449999668,5.523427473000083,"Sort (cost=1482107.53..1482108.81 rows=515 width=96) (actual time=3575.569..3578.432 rows=1 loops=1) + Sort Key: s.s_suppkey + Sort Method: quicksort Memory: 25kB + CTE revenue + -> Finalize GroupAggregate (cost=1447506.82..1474380.59 rows=103024 width=36) (actual time=3390.785..3539.765 rows=100000 loops=1) + Group Key: l.l_suppkey + -> Gather Merge (cost=1447506.82..1471547.43 rows=206048 width=36) (actual time=3390.745..3436.361 rows=299619 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1446506.79..1446764.35 rows=103024 width=36) (actual time=3351.990..3361.338 rows=99873 loops=3) + Sort Key: l.l_suppkey + Sort Method: external merge Disk: 7920kB + Worker 0: Sort Method: external merge Disk: 7928kB + Worker 1: Sort Method: external merge Disk: 7936kB + -> Partial HashAggregate (cost=1424721.37..1435111.20 rows=103024 width=36) (actual time=2930.845..3315.743 rows=99873 loops=3) + Group Key: l.l_suppkey + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 23392kB + Worker 0: Batches: 21 Memory Usage: 8249kB Disk Usage: 23856kB + Worker 1: Batches: 21 Memory Usage: 8249kB Disk Usage: 36240kB + -> Parallel Seq Scan on lineitem l (cost=0.00..1360351.80 rows=932048 width=16) (actual time=200.513..2333.962 rows=755238 loops=3) + Filter: ((l_shipdate >= '1996-01-01'::date) AND (l_shipdate < '1996-04-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 19240113 + InitPlan 2 (returns $2) + -> Aggregate (cost=2318.04..2318.05 rows=1 width=32) (actual time=173.269..173.270 rows=1 loops=1) + -> CTE Scan on revenue (cost=0.00..2060.48 rows=103024 width=32) (actual time=0.001..165.227 rows=100000 loops=1) + -> Nested Loop (cost=0.29..5385.69 rows=515 width=96) (actual time=3572.130..3575.566 rows=1 loops=1) + -> CTE Scan on revenue r (cost=0.00..2318.04 rows=515 width=36) (actual time=3572.097..3575.532 rows=1 loops=1) + Filter: (total_revenue = $2) + Rows Removed by Filter: 99999 + -> Index Scan using supplier_pkey on supplier s (cost=0.29..5.96 rows=1 width=64) (actual time=0.018..0.018 rows=1 loops=1) + Index Cond: (s_suppkey = r.supplier_no) +Planning Time: 0.164 ms +JIT: + Functions: 50 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.335 ms, Inlining 225.310 ms, Optimization 408.114 ms, Emission 280.069 ms, Total 917.828 ms +Execution Time: 3583.881 ms","Sort (cost=1719275.52..1719275.52 rows=1 width=96) (actual time=5582.888..5582.994 rows=1 loops=1) + Sort Key: supplier.s_suppkey NULLS FIRST + Sort Method: quicksort Memory: 25kB + CTE _t3 + -> Gather (cost=1000.00..1585043.40 rows=2236916 width=20) (actual time=188.459..1634.718 rows=2265714 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on lineitem (cost=0.00..1360351.80 rows=932048 width=20) (actual time=144.442..2363.008 rows=755238 loops=3) + Filter: ((l_shipdate < '1996-04-01'::date) AND (l_shipdate >= '1996-01-01'::date)) + Rows Removed by Filter: 19240113 + -> Nested Loop (cost=134220.27..134232.11 rows=1 width=96) (actual time=5417.018..5582.886 rows=1 loops=1) + -> Hash Join (cost=134219.98..134225.02 rows=1 width=36) (actual time=5416.991..5582.857 rows=1 loops=1) + Hash Cond: (COALESCE((sum((_t3.l_extendedprice * ('1'::numeric - _t3.l_discount)))), '0'::numeric) = (max(COALESCE((sum((_t3_1.l_extendedprice * ('1'::numeric - _t3_1.l_discount)))), '0'::numeric)))) + -> HashAggregate (cost=67107.48..67109.98 rows=200 width=36) (actual time=3068.083..3723.427 rows=100000 loops=1) + Group Key: _t3.l_suppkey + Batches: 21 Memory Usage: 8265kB Disk Usage: 69488kB + -> CTE Scan on _t3 (cost=0.00..44738.32 rows=2236916 width=40) (actual time=188.463..2020.775 rows=2265714 loops=1) + -> Hash (cost=67112.49..67112.49 rows=1 width=32) (actual time=1852.841..1852.843 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Aggregate (cost=67112.48..67112.49 rows=1 width=32) (actual time=1852.835..1852.836 rows=1 loops=1) + -> HashAggregate (cost=67107.48..67109.98 rows=200 width=36) (actual time=1166.297..1848.557 rows=100000 loops=1) + Group Key: _t3_1.l_suppkey + Batches: 21 Memory Usage: 8265kB Disk Usage: 69488kB + -> CTE Scan on _t3 _t3_1 (cost=0.00..44738.32 rows=2236916 width=40) (actual time=0.010..179.287 rows=2265714 loops=1) + -> Index Scan using supplier_pkey on supplier (cost=0.29..7.09 rows=1 width=64) (actual time=0.019..0.019 rows=1 loops=1) + Index Cond: (s_suppkey = _t3.l_suppkey) +Planning Time: 0.227 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.026 ms, Inlining 182.681 ms, Optimization 222.621 ms, Emission 142.959 ms, Total 551.286 ms +Execution Time: 5612.662 ms",SUCCESS +15,16,TPCH,Q16,"SELECT + p.p_brand, + p.p_type, + p.p_size, + COUNT(DISTINCT ps.ps_suppkey) AS supplier_count +FROM + tpch.part p +JOIN tpch.partsupp ps + ON p.p_partkey = ps.ps_partkey +WHERE + p.p_brand <> 'Brand#45' + AND p.p_type NOT LIKE 'MEDIUM POLISHED%' + AND p.p_size IN (49, 14, 23, 45, 19, 3, 36, 9) + AND ps.ps_suppkey NOT IN ( + SELECT + s.s_suppkey + FROM + tpch.supplier s + WHERE + s.s_comment LIKE '%Customer%Complaints%' + ) +GROUP BY + p.p_brand, + p.p_type, + p.p_size +ORDER BY + supplier_count DESC, + p.p_brand, + p.p_type, + p.p_size +LIMIT 10;","valid_part = part.WHERE( + (brand != ""BRAND#45"") + & ~STARTSWITH(part_type, ""MEDIUM POLISHED%"") + & ISIN(size, [49, 14, 23, 45, 19, 3, 36, 9]) +) +result = ( + supply_records.WHERE( + ~LIKE(supplier.comment, ""%Customer%Complaints%"") & HAS(valid_part) + ) + .CALCULATE( + P_BRAND=valid_part.brand, + P_TYPE=valid_part.part_type, + P_SIZE=valid_part.size, + ) + .PARTITION(name=""groups"", by=(P_BRAND, P_TYPE, P_SIZE)) + .CALCULATE( + P_BRAND, + P_TYPE, + P_SIZE, + SUPPLIER_COUNT=NDISTINCT(supply_records.supplier_key), + ) + .TOP_K( + 10, by=(SUPPLIER_COUNT.DESC(), P_BRAND.ASC(), P_TYPE.ASC(), P_SIZE.ASC()) + ) +)","SELECT + part.p_brand AS P_BRAND, + part.p_type AS P_TYPE, + part.p_size AS P_SIZE, + COUNT(DISTINCT partsupp.ps_suppkey) AS SUPPLIER_COUNT +FROM tpch.partsupp AS partsupp +JOIN tpch.supplier AS supplier + ON NOT supplier.s_comment LIKE '%Customer%Complaints%' + AND partsupp.ps_suppkey = supplier.s_suppkey +JOIN tpch.part AS part + ON NOT part.p_type LIKE 'MEDIUM POLISHED%%' + AND part.p_brand <> 'BRAND#45' + AND part.p_partkey = partsupp.ps_partkey + AND part.p_size IN (49, 14, 23, 45, 19, 3, 36, 9) +GROUP BY + 1, + 2, + 3 +ORDER BY + 4 DESC NULLS LAST, + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST +LIMIT 10",3.4345684689999416,2.5460667150000518,"Limit (cost=364545.53..364545.56 rows=10 width=42) (actual time=3322.603..3364.828 rows=10 loops=1) + -> Sort (cost=364545.53..364933.15 rows=155048 width=42) (actual time=3313.451..3355.674 rows=10 loops=1) + Sort Key: (count(DISTINCT ps.ps_suppkey)) DESC, p.p_brand, p.p_type, p.p_size + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=282929.20..361195.00 rows=155048 width=42) (actual time=2768.154..3351.108 rows=27840 loops=1) + Group Key: p.p_brand, p.p_type, p.p_size + -> Gather Merge (cost=282929.20..353578.46 rows=606606 width=38) (actual time=2768.094..3217.694 rows=1186602 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=281929.17..282561.05 rows=252752 width=38) (actual time=2728.441..3022.195 rows=395534 loops=3) + Sort Key: p.p_brand, p.p_type, p.p_size, ps.ps_suppkey + Sort Method: external merge Disk: 15616kB + Worker 0: Sort Method: external merge Disk: 27112kB + Worker 1: Sort Method: external merge Disk: 15600kB + -> Parallel Hash Join (cost=63980.54..252335.51 rows=252752 width=38) (actual time=1303.703..1621.501 rows=395534 loops=3) + Hash Cond: (ps.ps_partkey = p.p_partkey) + -> Parallel Index Only Scan using partsupp_pkey on partsupp ps (cost=3386.46..173356.32 rows=1666704 width=8) (actual time=26.595..672.179 rows=2665173 loops=3) + Filter: (NOT (hashed SubPlan 1)) + Rows Removed by Filter: 1493 + Heap Fetches: 0 + SubPlan 1 + -> Seq Scan on supplier s (cost=0.00..3386.00 rows=10 width=4) (actual time=0.313..25.984 rows=56 loops=3) + Filter: ((s_comment)::text ~~ '%Customer%Complaints%'::text) + Rows Removed by Filter: 99944 + -> Parallel Hash (cost=58026.62..58026.62 rows=126357 width=38) (actual time=192.780..192.781 rows=98941 loops=3) + Buckets: 131072 Batches: 4 Memory Usage: 6400kB + -> Parallel Seq Scan on part p (cost=0.00..58026.62 rows=126357 width=38) (actual time=7.651..165.080 rows=98941 loops=3) + Filter: (((p_brand)::text <> 'Brand#45'::text) AND ((p_type)::text !~~ 'MEDIUM POLISHED%'::text) AND (p_size = ANY ('{49,14,23,45,19,3,36,9}'::integer[]))) + Rows Removed by Filter: 567725 +Planning Time: 0.349 ms +JIT: + Functions: 79 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 4.168 ms, Inlining 0.000 ms, Optimization 2.135 ms, Emission 30.657 ms, Total 36.960 ms +Execution Time: 3368.289 ms","Limit (cost=448901.86..448901.89 rows=10 width=42) (actual time=2612.603..2622.737 rows=10 loops=1) + -> Sort (cost=448901.86..449295.62 rows=157504 width=42) (actual time=2605.743..2615.876 rows=10 loops=1) + Sort Key: (count(DISTINCT partsupp.ps_suppkey)) DESC NULLS LAST, part.p_brand NULLS FIRST, part.p_type NULLS FIRST, part.p_size NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=286331.06..445498.26 rows=157504 width=42) (actual time=1808.187..2611.370 rows=29000 loops=1) + Group Key: part.p_brand, part.p_type, part.p_size + -> Gather Merge (cost=286331.06..431462.04 rows=1246118 width=38) (actual time=1808.107..2474.084 rows=1235619 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=285331.04..286629.08 rows=519216 width=38) (actual time=1763.090..2019.655 rows=411873 loops=3) + Sort Key: part.p_brand NULLS FIRST, part.p_type NULLS FIRST, part.p_size NULLS FIRST, partsupp.ps_suppkey + Sort Method: external merge Disk: 28880kB + Worker 0: Sort Method: external merge Disk: 15880kB + Worker 1: Sort Method: external merge Disk: 15952kB + -> Parallel Hash Join (cost=3606.95..221842.43 rows=519216 width=38) (actual time=19.411..580.209 rows=411873 loops=3) + Hash Cond: (partsupp.ps_suppkey = supplier.s_suppkey) + -> Nested Loop (cost=0.43..216854.34 rows=526293 width=38) (actual time=0.095..440.858 rows=412112 loops=3) + -> Parallel Seq Scan on part (cost=0.00..58026.62 rows=131553 width=38) (actual time=0.032..168.705 rows=103028 loops=3) + Filter: (((p_type)::text !~~ 'MEDIUM POLISHED%%'::text) AND ((p_brand)::text <> 'BRAND#45'::text) AND (p_size = ANY ('{49,14,23,45,19,3,36,9}'::integer[]))) + Rows Removed by Filter: 563639 + -> Index Only Scan using partsupp_pkey on partsupp (cost=0.43..1.03 rows=18 width=8) (actual time=0.002..0.002 rows=4 loops=309084) + Index Cond: (ps_partkey = part.p_partkey) + Heap Fetches: 0 + -> Parallel Hash (cost=2871.29..2871.29 rows=58818 width=4) (actual time=18.612..18.613 rows=33315 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4960kB + -> Parallel Seq Scan on supplier (cost=0.00..2871.29 rows=58818 width=4) (actual time=6.059..14.147 rows=33315 loops=3) + Filter: ((s_comment)::text !~~ '%Customer%Complaints%'::text) + Rows Removed by Filter: 19 +Planning Time: 0.582 ms +JIT: + Functions: 49 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.000 ms, Inlining 0.000 ms, Optimization 1.333 ms, Emission 23.740 ms, Total 28.073 ms +Execution Time: 2627.521 ms",SUCCESS +16,17,TPCH,Q17,"WITH avg_qty AS ( + SELECT + l_partkey, + 0.2 * AVG(l_quantity) AS avg_q + FROM tpch.lineitem + GROUP BY l_partkey +) +SELECT + SUM(l.l_extendedprice) / 7.0 AS avg_yearly +FROM tpch.lineitem l +JOIN tpch.part p + ON p.p_partkey = l.l_partkey +JOIN avg_qty a + ON a.l_partkey = l.l_partkey +WHERE p.p_brand = 'Brand#23' + AND p.p_container = 'MED BOX' + AND l.l_quantity < a.avg_q;","selected_lines = parts.WHERE( + (brand == ""Brand#23"") & (container == ""MED BOX"") +).lines.WHERE(quantity < 0.2 * RELAVG(quantity, per=""parts"")) +result = TPCH.CALCULATE(AVG_YEARLY=SUM(selected_lines.extended_price) / 7.0)","WITH _t AS ( + SELECT + lineitem.l_extendedprice, + lineitem.l_quantity, + AVG(CAST(lineitem.l_quantity AS DOUBLE PRECISION)) OVER (PARTITION BY lineitem.l_partkey) AS _w + FROM tpch.part AS part + JOIN tpch.lineitem AS lineitem + ON lineitem.l_partkey = part.p_partkey + WHERE + part.p_brand = 'Brand#23' AND part.p_container = 'MED BOX' +) +SELECT + CAST(COALESCE(SUM(l_extendedprice), 0) AS DOUBLE PRECISION) / 7.0 AS AVG_YEARLY +FROM _t +WHERE + l_quantity < ( + 0.2 * _w + )",27.299716287000138,3.27963325599967,"Aggregate (cost=5290808.36..5290808.37 rows=1 width=32) (actual time=30479.593..30479.945 rows=1 loops=1) + -> Hash Join (cost=3968646.75..5290763.02 rows=18135 width=8) (actual time=26466.463..30479.329 rows=5526 loops=1) + Hash Cond: (p.p_partkey = lineitem.l_partkey) + Join Filter: (l.l_quantity < ((0.2 * avg(lineitem.l_quantity)))) + Rows Removed by Join Filter: 55859 + -> Gather (cost=50704.65..1357610.55 rows=59188 width=21) (actual time=275.048..4152.487 rows=61385 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=49704.65..1350691.75 rows=24662 width=21) (actual time=262.317..4359.786 rows=20462 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235373.20 rows=24995720 width=17) (actual time=0.026..2050.440 rows=19995351 loops=3) + -> Parallel Hash (cost=49694.38..49694.38 rows=822 width=4) (actual time=261.789..261.790 rows=681 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 144kB + -> Parallel Seq Scan on part p (cost=0.00..49694.38 rows=822 width=4) (actual time=194.077..261.554 rows=681 loops=3) + Filter: (((p_brand)::text = 'Brand#23'::text) AND ((p_container)::text = 'MED BOX'::text)) + Rows Removed by Filter: 665985 + -> Hash (cost=3880604.04..3880604.04 rows=1838165 width=36) (actual time=26190.460..26190.515 rows=2000000 loops=1) + Buckets: 131072 Batches: 32 Memory Usage: 4029kB + -> Finalize GroupAggregate (cost=3396523.98..3880604.04 rows=1838165 width=36) (actual time=22342.291..25860.728 rows=2000000 loops=1) + Group Key: lineitem.l_partkey + -> Gather Merge (cost=3396523.98..3825459.09 rows=3676330 width=36) (actual time=22342.242..23336.721 rows=5999634 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3395523.95..3400119.37 rows=1838165 width=36) (actual time=21474.818..21723.625 rows=1999878 loops=3) + Sort Key: lineitem.l_partkey + Sort Method: external merge Disk: 150728kB + Worker 0: Sort Method: external merge Disk: 150736kB + Worker 1: Sort Method: external merge Disk: 150744kB + -> Partial HashAggregate (cost=2836661.51..3103737.40 rows=1838165 width=36) (actual time=11164.655..20573.908 rows=1999878 loops=3) + Group Key: lineitem.l_partkey + Planned Partitions: 128 Batches: 129 Memory Usage: 8209kB Disk Usage: 742408kB + Worker 0: Batches: 129 Memory Usage: 8209kB Disk Usage: 777640kB + Worker 1: Batches: 129 Memory Usage: 8209kB Disk Usage: 890888kB + -> Parallel Seq Scan on lineitem (cost=0.00..1235373.20 rows=24995720 width=9) (actual time=0.012..2073.710 rows=19995351 loops=3) +Planning Time: 0.246 ms +JIT: + Functions: 81 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.799 ms, Inlining 464.645 ms, Optimization 422.377 ms, Emission 302.421 ms, Total 1194.242 ms +Execution Time: 30517.986 ms","Aggregate (cost=1362505.19..1362505.20 rows=1 width=8) (actual time=4366.779..4369.356 rows=1 loops=1) + -> Subquery Scan on _t (cost=1353490.87..1362455.86 rows=19729 width=8) (actual time=4323.957..4368.804 rows=5526 loops=1) + Filter: ((_t.l_quantity)::double precision < ('0.2'::double precision * _t._w)) + Rows Removed by Filter: 55859 + -> WindowAgg (cost=1353490.87..1361420.07 rows=59188 width=25) (actual time=4323.951..4359.504 rows=61385 loops=1) + -> Gather Merge (cost=1353490.87..1360384.28 rows=59188 width=17) (actual time=4323.877..4335.487 rows=61385 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1352490.84..1352552.50 rows=24662 width=17) (actual time=4310.465..4312.391 rows=20462 loops=3) + Sort Key: lineitem.l_partkey + Sort Method: quicksort Memory: 1611kB + Worker 0: Sort Method: quicksort Memory: 1599kB + Worker 1: Sort Method: quicksort Memory: 1889kB + -> Parallel Hash Join (cost=49704.65..1350691.75 rows=24662 width=17) (actual time=242.966..4302.827 rows=20462 loops=3) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1235373.20 rows=24995720 width=17) (actual time=0.015..2004.256 rows=19995351 loops=3) + -> Parallel Hash (cost=49694.38..49694.38 rows=822 width=4) (actual time=242.511..242.511 rows=681 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 144kB + -> Parallel Seq Scan on part (cost=0.00..49694.38 rows=822 width=4) (actual time=173.137..242.236 rows=681 loops=3) + Filter: (((p_brand)::text = 'Brand#23'::text) AND ((p_container)::text = 'MED BOX'::text)) + Rows Removed by Filter: 665985 +Planning Time: 0.250 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.254 ms, Inlining 163.775 ms, Optimization 205.262 ms, Emission 149.501 ms, Total 520.793 ms +Execution Time: 4370.374 ms",SUCCESS +17,18,TPCH,Q18,"SELECT + c.c_name, + c.c_custkey, + o.o_orderkey, + o.o_orderdate, + o.o_totalprice, + SUM(l.l_quantity) AS total_quantity +FROM + tpch.customer c +JOIN tpch.orders o + ON c.c_custkey = o.o_custkey +JOIN tpch.lineitem l + ON o.o_orderkey = l.l_orderkey +WHERE + o.o_orderkey IN ( + SELECT + l2.l_orderkey + FROM + tpch.lineitem l2 + GROUP BY + l2.l_orderkey + HAVING + SUM(l2.l_quantity) > 300 + ) +GROUP BY + c.c_name, + c.c_custkey, + o.o_orderkey, + o.o_orderdate, + o.o_totalprice +ORDER BY + o.o_totalprice DESC, + o.o_orderdate +LIMIT 10;","result = ( + orders.CALCULATE( + C_NAME=customer.name, + C_CUSTKEY=customer.key, + O_ORDERKEY=key, + O_ORDERDATE=order_date, + O_TOTALPRICE=total_price, + TOTAL_QUANTITY=SUM(lines.quantity), + ) + .WHERE(TOTAL_QUANTITY > 300) + .TOP_K( + 10, + by=(O_TOTALPRICE.DESC(), O_ORDERDATE.ASC()), + ) + )","WITH _t1 AS ( + SELECT + l_orderkey, + SUM(l_quantity) AS sum_l_quantity + FROM tpch.lineitem + GROUP BY + 1 +) +SELECT + customer.c_name AS C_NAME, + customer.c_custkey AS C_CUSTKEY, + orders.o_orderkey AS O_ORDERKEY, + orders.o_orderdate AS O_ORDERDATE, + orders.o_totalprice AS O_TOTALPRICE, + _t1.sum_l_quantity AS TOTAL_QUANTITY +FROM tpch.orders AS orders +JOIN tpch.customer AS customer + ON customer.c_custkey = orders.o_custkey +JOIN _t1 AS _t1 + ON NOT _t1.sum_l_quantity IS NULL + AND _t1.l_orderkey = orders.o_orderkey + AND _t1.sum_l_quantity > 300 +ORDER BY + 5 DESC NULLS LAST, + 4 NULLS FIRST +LIMIT 10",50.75433818900001,42.697238967999965,"Limit (cost=6226335.65..6226335.67 rows=10 width=71) (actual time=55054.447..55054.564 rows=10 loops=1) + -> Sort (cost=6226335.65..6227812.93 rows=590915 width=71) (actual time=54839.458..54839.574 rows=10 loops=1) + Sort Key: o.o_totalprice DESC, o.o_orderdate + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=6086285.78..6213566.19 rows=590915 width=71) (actual time=54535.924..54839.386 rows=624 loops=1) + Group Key: c.c_custkey, o.o_orderkey + -> Incremental Sort (cost=6086285.78..6201747.89 rows=590915 width=44) (actual time=54535.908..54838.601 rows=4368 loops=1) + Sort Key: c.c_custkey, o.o_orderkey + Presorted Key: c.c_custkey + Full-sort Groups: 125 Sort Method: quicksort Average Memory: 27kB Peak Memory: 27kB + -> Merge Join (cost=6086285.62..6175156.71 rows=590915 width=44) (actual time=54534.288..54837.692 rows=4368 loops=1) + Merge Cond: (c.c_custkey = o.o_custkey) + -> Index Scan using customer_pkey on customer c (cost=0.43..74781.00 rows=1500097 width=23) (actual time=0.027..229.476 rows=1499744 loops=1) + -> Materialize (cost=6086284.90..6089239.48 rows=590915 width=25) (actual time=54533.459..54534.419 rows=4368 loops=1) + -> Sort (cost=6086284.90..6087762.19 rows=590915 width=25) (actual time=54533.456..54533.970 rows=4368 loops=1) + Sort Key: o.o_custkey + Sort Method: quicksort Memory: 431kB + -> Hash Join (cost=3937061.20..6015498.04 rows=590915 width=25) (actual time=45106.756..54532.747 rows=4368 loops=1) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Hash Join (cost=3259549.40..5002337.22 rows=19996576 width=13) (actual time=40570.196..49073.649 rows=4368 loops=1) + Hash Cond: (l.l_orderkey = l2.l_orderkey) + -> Seq Scan on lineitem l (cost=0.00..1585313.28 rows=59989728 width=9) (actual time=0.023..4872.977 rows=59986052 loops=1) + -> Hash (cost=3257702.75..3257702.75 rows=147732 width=4) (actual time=40568.780..40568.891 rows=624 loops=1) + Buckets: 262144 Batches: 1 Memory Usage: 2070kB + -> Finalize GroupAggregate (cost=3140987.25..3257702.75 rows=147732 width=4) (actual time=31170.860..40568.392 rows=624 loops=1) + Group Key: l2.l_orderkey + Filter: (sum(l2.l_quantity) > '300'::numeric) + Rows Removed by Filter: 14999376 + -> Gather Merge (cost=3140987.25..3244406.87 rows=886392 width=36) (actual time=31169.754..33673.835 rows=15008320 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3139987.22..3141095.21 rows=443196 width=36) (actual time=28073.010..28774.451 rows=5002773 loops=3) + Sort Key: l2.l_orderkey + Sort Method: external merge Disk: 366392kB + Worker 0: Sort Method: external merge Disk: 404304kB + Worker 1: Sort Method: external merge Disk: 360336kB + -> Partial HashAggregate (cost=2836661.51..3086300.29 rows=443196 width=36) (actual time=11115.796..25098.474 rows=5002773 loops=3) + Group Key: l2.l_orderkey + Planned Partitions: 32 Batches: 553 Memory Usage: 8345kB Disk Usage: 718168kB + Worker 0: Batches: 569 Memory Usage: 8345kB Disk Usage: 785976kB + Worker 1: Batches: 513 Memory Usage: 8345kB Disk Usage: 714768kB + -> Parallel Seq Scan on lineitem l2 (cost=0.00..1235373.20 rows=24995720 width=9) (actual time=0.012..2534.784 rows=19995351 loops=3) + -> Hash (cost=402161.69..402161.69 rows=14997769 width=20) (actual time=4147.232..4147.232 rows=15000000 loops=1) + Buckets: 131072 Batches: 128 Memory Usage: 7409kB + -> Seq Scan on orders o (cost=0.00..402161.69 rows=14997769 width=20) (actual time=0.015..1693.261 rows=15000000 loops=1) +Planning Time: 3.156 ms +JIT: + Functions: 64 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.031 ms, Inlining 185.849 ms, Optimization 272.385 ms, Emission 181.055 ms, Total 644.320 ms +Execution Time: 55115.609 ms","Limit (cost=3950745.92..3950745.94 rows=10 width=71) (actual time=45651.747..45651.862 rows=10 loops=1) + -> Sort (cost=3950745.92..3951113.40 rows=146993 width=71) (actual time=45546.267..45546.381 rows=10 loops=1) + Sort Key: orders.o_totalprice DESC NULLS LAST, orders.o_orderdate NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> Nested Loop (cost=3262159.52..3947569.45 rows=146993 width=71) (actual time=41634.606..45546.022 rows=624 loops=1) + -> Hash Join (cost=3262159.09..3880594.94 rows=146993 width=52) (actual time=41634.582..45543.076 rows=624 loops=1) + Hash Cond: (orders.o_orderkey = _t1.l_orderkey) + -> Seq Scan on orders (cost=0.00..402161.69 rows=14997769 width=20) (actual time=0.024..1473.702 rows=15000000 loops=1) + -> Hash (cost=3259172.68..3259172.68 rows=146993 width=36) (actual time=41633.883..41633.994 rows=624 loops=1) + Buckets: 131072 Batches: 2 Memory Usage: 1037kB + -> Subquery Scan on _t1 (cost=3140987.25..3259172.68 rows=146993 width=36) (actual time=32153.246..41633.430 rows=624 loops=1) + -> Finalize GroupAggregate (cost=3140987.25..3257702.75 rows=146993 width=36) (actual time=32153.243..41633.296 rows=624 loops=1) + Group Key: lineitem.l_orderkey + Filter: ((sum(lineitem.l_quantity) IS NOT NULL) AND (sum(lineitem.l_quantity) > '300'::numeric)) + Rows Removed by Filter: 14999376 + -> Gather Merge (cost=3140987.25..3244406.87 rows=886392 width=36) (actual time=32152.193..34726.269 rows=15008135 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3139987.22..3141095.21 rows=443196 width=36) (actual time=27365.668..28018.620 rows=5002712 loops=3) + Sort Key: lineitem.l_orderkey + Sort Method: external merge Disk: 506048kB + Worker 0: Sort Method: external merge Disk: 312552kB + Worker 1: Sort Method: external merge Disk: 312424kB + -> Partial HashAggregate (cost=2836661.51..3086300.29 rows=443196 width=36) (actual time=10604.303..24596.805 rows=5002712 loops=3) + Group Key: lineitem.l_orderkey + Planned Partitions: 32 Batches: 785 Memory Usage: 8345kB Disk Usage: 981920kB + Worker 0: Batches: 441 Memory Usage: 8345kB Disk Usage: 619704kB + Worker 1: Batches: 441 Memory Usage: 8345kB Disk Usage: 619712kB + -> Parallel Seq Scan on lineitem (cost=0.00..1235373.20 rows=24995720 width=9) (actual time=0.032..2145.591 rows=19995351 loops=3) + -> Index Scan using customer_pkey on customer (cost=0.43..0.46 rows=1 width=23) (actual time=0.004..0.004 rows=1 loops=624) + Index Cond: (c_custkey = orders.o_custkey) +Planning Time: 0.288 ms +JIT: + Functions: 49 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.884 ms, Inlining 200.452 ms, Optimization 211.774 ms, Emission 142.458 ms, Total 557.569 ms +Execution Time: 45758.877 ms",SUCCESS +18,19,TPCH,Q19,"SELECT + SUM(l.l_extendedprice * (1 - l.l_discount)) AS revenue +FROM + tpch.lineitem l +JOIN tpch.part p + ON p.p_partkey = l.l_partkey +WHERE + ( + p.p_brand = 'Brand#12' + AND p.p_container IN ( + 'SM CASE', 'SM BOX', 'SM PACK', 'SM PKG' + ) + AND l.l_quantity BETWEEN 1 AND 11 + AND p.p_size BETWEEN 1 AND 5 + AND l.l_shipmode IN ('AIR', 'AIR REG') + AND l.l_shipinstruct = 'DELIVER IN PERSON' + ) + OR ( + p.p_brand = 'Brand#23' + AND p.p_container IN ( + 'MED BAG', 'MED BOX', 'MED PKG', 'MED PACK' + ) + AND l.l_quantity BETWEEN 10 AND 20 + AND p.p_size BETWEEN 1 AND 10 + AND l.l_shipmode IN ('AIR', 'AIR REG') + AND l.l_shipinstruct = 'DELIVER IN PERSON' + ) + OR ( + p.p_brand = 'Brand#34' + AND p.p_container IN ( + 'LG CASE', 'LG BOX', 'LG PACK', 'LG PKG' + ) + AND l.l_quantity BETWEEN 20 AND 30 + AND p.p_size BETWEEN 1 AND 15 + AND l.l_shipmode IN ('AIR', 'AIR REG') + AND l.l_shipinstruct = 'DELIVER IN PERSON' + );","selected_lines = lines.WHERE( + (ISIN(ship_mode, (""AIR"", ""AIR REG""))) + & (ship_instruct == ""DELIVER IN PERSON"") + & ( + ( + MONOTONIC(1, part.size, 5) + & MONOTONIC(1, quantity, 11) + & ISIN( + part.container, + (""SM CASE"", ""SM BOX"", ""SM PACK"", ""SM PKG""), + ) + & (part.brand == ""Brand#12"") + ) + | ( + MONOTONIC(1, part.size, 10) + & MONOTONIC(10, quantity, 20) + & ISIN( + part.container, + (""MED BAG"", ""MED BOX"", ""MED PACK"", ""MED PKG""), + ) + & (part.brand == ""Brand#23"") + ) + | ( + MONOTONIC(1, part.size, 15) + & MONOTONIC(20, quantity, 30) + & ISIN( + part.container, + (""LG CASE"", ""LG BOX"", ""LG PACK"", ""LG PKG""), + ) + & (part.brand == ""Brand#34"") + ) + ) +) +result = TPCH.CALCULATE( + REVENUE=SUM(selected_lines.extended_price * (1 - selected_lines.discount)) +)","SELECT + COALESCE(SUM(lineitem.l_extendedprice * ( + 1 - lineitem.l_discount + )), 0) AS REVENUE +FROM tpch.lineitem AS lineitem +JOIN tpch.part AS part + ON ( + ( + lineitem.l_quantity <= 11 + AND lineitem.l_quantity >= 1 + AND part.p_brand = 'Brand#12' + AND part.p_container IN ('SM CASE', 'SM BOX', 'SM PACK', 'SM PKG') + AND part.p_size <= 5 + AND part.p_size >= 1 + ) + OR ( + lineitem.l_quantity <= 20 + AND lineitem.l_quantity >= 10 + AND part.p_brand = 'Brand#23' + AND part.p_container IN ('MED BAG', 'MED BOX', 'MED PACK', 'MED PKG') + AND part.p_size <= 10 + AND part.p_size >= 1 + ) + OR ( + lineitem.l_quantity <= 30 + AND lineitem.l_quantity >= 20 + AND part.p_brand = 'Brand#34' + AND part.p_container IN ('LG CASE', 'LG BOX', 'LG PACK', 'LG PKG') + AND part.p_size <= 15 + AND part.p_size >= 1 + ) + ) + AND lineitem.l_partkey = part.p_partkey +WHERE + lineitem.l_shipinstruct = 'DELIVER IN PERSON' + AND lineitem.l_shipmode IN ('AIR', 'AIR REG')",3.9509516190000795,4.05090557099993,"Finalize Aggregate (cost=1810137.59..1810137.60 rows=1 width=32) (actual time=3963.154..3969.406 rows=1 loops=1) + -> Gather (cost=1810137.36..1810137.57 rows=2 width=32) (actual time=3962.943..3969.385 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1809137.36..1809137.37 rows=1 width=32) (actual time=3948.528..3948.531 rows=1 loops=3) + -> Parallel Hash Join (cost=72632.57..1809133.91 rows=460 width=12) (actual time=442.554..3948.165 rows=378 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + Join Filter: ((((p.p_brand)::text = 'Brand#12'::text) AND ((p.p_container)::text = ANY ('{""SM CASE"",""SM BOX"",""SM PACK"",""SM PKG""}'::text[])) AND (l.l_quantity >= '1'::numeric) AND (l.l_quantity <= '11'::numeric) AND (p.p_size <= 5)) OR (((p.p_brand)::text = 'Brand#23'::text) AND ((p.p_container)::text = ANY ('{""MED BAG"",""MED BOX"",""MED PKG"",""MED PACK""}'::text[])) AND (l.l_quantity >= '10'::numeric) AND (l.l_quantity <= '20'::numeric) AND (p.p_size <= 10)) OR (((p.p_brand)::text = 'Brand#34'::text) AND ((p.p_container)::text = ANY ('{""LG CASE"",""LG BOX"",""LG PACK"",""LG PKG""}'::text[])) AND (l.l_quantity >= '20'::numeric) AND (l.l_quantity <= '30'::numeric) AND (p.p_size <= 15))) + Rows Removed by Join Filter: 639 + -> Parallel Seq Scan on lineitem l (cost=0.00..1735287.60 rows=462376 width=21) (actual time=0.066..3465.745 rows=428115 loops=3) + Filter: (((l_shipmode)::text = ANY ('{AIR,""AIR REG""}'::text[])) AND ((l_shipinstruct)::text = 'DELIVER IN PERSON'::text) AND (((l_quantity >= '1'::numeric) AND (l_quantity <= '11'::numeric)) OR ((l_quantity >= '10'::numeric) AND (l_quantity <= '20'::numeric)) OR ((l_quantity >= '20'::numeric) AND (l_quantity <= '30'::numeric)))) + Rows Removed by Filter: 19567236 + -> Parallel Hash (cost=72608.06..72608.06 rows=1961 width=25) (actual time=426.118..426.119 rows=1585 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 384kB + -> Parallel Seq Scan on part p (cost=0.00..72608.06 rows=1961 width=25) (actual time=310.611..425.466 rows=1585 loops=3) + Filter: ((p_size >= 1) AND ((((p_brand)::text = 'Brand#12'::text) AND ((p_container)::text = ANY ('{""SM CASE"",""SM BOX"",""SM PACK"",""SM PKG""}'::text[])) AND (p_size <= 5)) OR (((p_brand)::text = 'Brand#23'::text) AND ((p_container)::text = ANY ('{""MED BAG"",""MED BOX"",""MED PKG"",""MED PACK""}'::text[])) AND (p_size <= 10)) OR (((p_brand)::text = 'Brand#34'::text) AND ((p_container)::text = ANY ('{""LG CASE"",""LG BOX"",""LG PACK"",""LG PKG""}'::text[])) AND (p_size <= 15)))) + Rows Removed by Filter: 665082 +Planning Time: 0.297 ms +JIT: + Functions: 59 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.335 ms, Inlining 171.992 ms, Optimization 437.585 ms, Emission 321.992 ms, Total 936.903 ms +Execution Time: 3970.895 ms","Finalize Aggregate (cost=1810137.59..1810137.60 rows=1 width=32) (actual time=3936.497..3943.239 rows=1 loops=1) + -> Gather (cost=1810137.36..1810137.57 rows=2 width=32) (actual time=3936.290..3943.218 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1809137.36..1809137.37 rows=1 width=32) (actual time=3918.599..3918.601 rows=1 loops=3) + -> Parallel Hash Join (cost=72632.57..1809133.91 rows=460 width=12) (actual time=423.031..3918.202 rows=378 loops=3) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + Join Filter: (((lineitem.l_quantity <= '11'::numeric) AND (lineitem.l_quantity >= '1'::numeric) AND ((part.p_brand)::text = 'Brand#12'::text) AND ((part.p_container)::text = ANY ('{""SM CASE"",""SM BOX"",""SM PACK"",""SM PKG""}'::text[])) AND (part.p_size <= 5)) OR ((lineitem.l_quantity <= '20'::numeric) AND (lineitem.l_quantity >= '10'::numeric) AND ((part.p_brand)::text = 'Brand#23'::text) AND ((part.p_container)::text = ANY ('{""MED BAG"",""MED BOX"",""MED PACK"",""MED PKG""}'::text[])) AND (part.p_size <= 10)) OR ((lineitem.l_quantity <= '30'::numeric) AND (lineitem.l_quantity >= '20'::numeric) AND ((part.p_brand)::text = 'Brand#34'::text) AND ((part.p_container)::text = ANY ('{""LG CASE"",""LG BOX"",""LG PACK"",""LG PKG""}'::text[])) AND (part.p_size <= 15))) + Rows Removed by Join Filter: 639 + -> Parallel Seq Scan on lineitem (cost=0.00..1735287.60 rows=462376 width=21) (actual time=0.071..3451.507 rows=428115 loops=3) + Filter: (((l_shipmode)::text = ANY ('{AIR,""AIR REG""}'::text[])) AND ((l_shipinstruct)::text = 'DELIVER IN PERSON'::text) AND (((l_quantity <= '11'::numeric) AND (l_quantity >= '1'::numeric)) OR ((l_quantity <= '20'::numeric) AND (l_quantity >= '10'::numeric)) OR ((l_quantity <= '30'::numeric) AND (l_quantity >= '20'::numeric)))) + Rows Removed by Filter: 19567236 + -> Parallel Hash (cost=72608.06..72608.06 rows=1961 width=25) (actual time=409.632..409.632 rows=1585 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 384kB + -> Parallel Seq Scan on part (cost=0.00..72608.06 rows=1961 width=25) (actual time=304.835..409.061 rows=1585 loops=3) + Filter: ((p_size >= 1) AND ((((p_brand)::text = 'Brand#12'::text) AND ((p_container)::text = ANY ('{""SM CASE"",""SM BOX"",""SM PACK"",""SM PKG""}'::text[])) AND (p_size <= 5)) OR (((p_brand)::text = 'Brand#23'::text) AND ((p_container)::text = ANY ('{""MED BAG"",""MED BOX"",""MED PACK"",""MED PKG""}'::text[])) AND (p_size <= 10)) OR (((p_brand)::text = 'Brand#34'::text) AND ((p_container)::text = ANY ('{""LG CASE"",""LG BOX"",""LG PACK"",""LG PKG""}'::text[])) AND (p_size <= 15)))) + Rows Removed by Filter: 665082 +Planning Time: 0.391 ms +JIT: + Functions: 59 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.800 ms, Inlining 177.233 ms, Optimization 422.169 ms, Emission 314.852 ms, Total 920.054 ms +Execution Time: 3944.845 ms",SUCCESS +19,20,TPCH,Q20,"WITH forest_parts AS ( + SELECT p_partkey + FROM tpch.part + WHERE p_name LIKE 'forest%' +), +lineitem_agg AS ( + SELECT + l_partkey, + l_suppkey, + 0.5 * SUM(l_quantity) AS half_qty + FROM tpch.lineitem + WHERE + l_shipdate >= DATE '1994-01-01' + AND l_shipdate < DATE '1994-01-01' + INTERVAL '1' YEAR + GROUP BY l_partkey, l_suppkey +), +qualified_suppliers AS ( + SELECT DISTINCT ps.ps_suppkey + FROM tpch.partsupp ps + JOIN forest_parts fp + ON ps.ps_partkey = fp.p_partkey + JOIN lineitem_agg la + ON la.l_partkey = ps.ps_partkey + AND la.l_suppkey = ps.ps_suppkey + WHERE ps.ps_availqty > la.half_qty +) +SELECT + s.s_name, + s.s_address +FROM tpch.supplier s +JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey +JOIN qualified_suppliers qs + ON s.s_suppkey = qs.ps_suppkey +WHERE + n.n_name = 'CANADA' +ORDER BY + s.s_name +LIMIT 10;","selected_lines = lines.WHERE(YEAR(ship_date) == 1994) +selected_parts_supplied = supply_records.WHERE( + HAS(part.WHERE(STARTSWITH(name, 'forest'))) + & (available_quantity > 0.5 * SUM(selected_lines.quantity)) + & HAS(selected_lines) +) +result = ( + suppliers.CALCULATE(S_NAME=name, S_ADDRESS=address) + .WHERE( + (nation.name == 'CANADA') + & HAS(selected_parts_supplied) + ) + .TOP_K(10, by=S_NAME.ASC()) +)","WITH _s5 AS ( + SELECT + l_partkey, + l_suppkey, + SUM(l_quantity) AS sum_l_quantity + FROM tpch.lineitem + WHERE + EXTRACT(YEAR FROM CAST(l_shipdate AS TIMESTAMP)) = 1994 + GROUP BY + 1, + 2 +), _u_0 AS ( + SELECT + partsupp.ps_suppkey AS _u_1 + FROM tpch.partsupp AS partsupp + JOIN tpch.part AS part + ON part.p_name LIKE 'forest%' AND part.p_partkey = partsupp.ps_partkey + JOIN _s5 AS _s5 + ON _s5.l_partkey = partsupp.ps_partkey + AND _s5.l_suppkey = partsupp.ps_suppkey + AND partsupp.ps_availqty > ( + 0.5 * COALESCE(_s5.sum_l_quantity, 0) + ) + GROUP BY + 1 +) +SELECT + supplier.s_name AS S_NAME, + supplier.s_address AS S_ADDRESS +FROM tpch.supplier AS supplier +JOIN tpch.nation AS nation + ON nation.n_name = 'CANADA' AND nation.n_nationkey = supplier.s_nationkey +LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = supplier.s_suppkey +WHERE + NOT _u_0._u_1 IS NULL +ORDER BY + 1 NULLS FIRST +LIMIT 10",15.796140729999934,12.485393134000333,"Limit (cost=2756045.85..2756129.49 rows=1 width=44) (actual time=13687.883..13743.855 rows=10 loops=1) + -> Nested Loop (cost=2756045.85..2756129.49 rows=1 width=44) (actual time=13481.915..13537.886 rows=10 loops=1) + Join Filter: (s.s_suppkey = ps.ps_suppkey) + Rows Removed by Join Filter: 803023 + -> Gather Merge (cost=3907.27..3967.22 rows=526 width=48) (actual time=23.646..23.735 rows=28 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2907.26..2908.04 rows=309 width=48) (actual time=10.764..10.767 rows=14 loops=2) + Sort Key: s.s_name + Sort Method: quicksort Memory: 399kB + Worker 0: Sort Method: quicksort Memory: 25kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=48) (actual time=0.025..8.547 rows=2027 loops=2) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=52) (actual time=0.007..5.069 rows=50000 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.023..0.024 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n (cost=0.00..12.38 rows=1 width=4) (actual time=0.017..0.019 rows=1 loops=1) + Filter: ((n_name)::text = 'CANADA'::text) + Rows Removed by Filter: 24 + -> Materialize (cost=2752138.58..2752138.61 rows=3 width=4) (actual time=480.160..481.589 rows=28680 loops=28) + -> Unique (cost=2752138.58..2752138.59 rows=3 width=4) (actual time=13444.487..13452.667 rows=44482 loops=1) + -> Sort (cost=2752138.58..2752138.59 rows=3 width=4) (actual time=13444.486..13446.875 rows=58655 loops=1) + Sort Key: ps.ps_suppkey + Sort Method: quicksort Memory: 1537kB + -> Nested Loop (cost=2546062.10..2752138.56 rows=3 width=4) (actual time=8510.596..13436.360 rows=58655 loops=1) + Join Filter: (ps.ps_partkey = part.p_partkey) + -> Hash Join (cost=2546061.67..2721122.92 rows=49045 width=44) (actual time=8510.558..13097.875 rows=58782 loops=1) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> HashAggregate (cost=2495177.97..2657493.50 rows=4855503 width=40) (actual time=8369.685..12481.970 rows=5441669 loops=1) + Group Key: lineitem.l_partkey, lineitem.l_suppkey + Planned Partitions: 256 Batches: 1281 Memory Usage: 8249kB Disk Usage: 507312kB + -> Seq Scan on lineitem (cost=0.00..1885261.92 rows=9163058 width=13) (actual time=0.030..5304.648 rows=9099165 loops=1) + Filter: ((l_shipdate >= '1994-01-01'::date) AND (l_shipdate < '1995-01-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 50886887 + -> Hash (cost=50631.21..50631.21 rows=20199 width=4) (actual time=140.791..140.841 rows=21551 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 1014kB + -> Gather (cost=1000.00..50631.21 rows=20199 width=4) (actual time=0.236..136.714 rows=21551 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on part (cost=0.00..47611.31 rows=8416 width=4) (actual time=51.030..124.657 rows=7184 loops=3) + Filter: ((p_name)::text ~~ 'forest%'::text) + Rows Removed by Filter: 659483 + -> Index Scan using partsupp_pkey on partsupp ps (cost=0.43..0.62 rows=1 width=12) (actual time=0.005..0.005 rows=1 loops=58782) + Index Cond: ((ps_partkey = lineitem.l_partkey) AND (ps_suppkey = lineitem.l_suppkey)) + Filter: ((ps_availqty)::numeric > ((0.5 * sum(lineitem.l_quantity)))) + Rows Removed by Filter: 0 +Planning Time: 0.558 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.338 ms, Inlining 151.419 ms, Optimization 152.483 ms, Emission 107.807 ms, Total 415.048 ms +Execution Time: 13811.240 ms","Limit (cost=1539981.11..1540048.96 rows=1 width=44) (actual time=13701.958..13758.009 rows=10 loops=1) + -> Nested Loop (cost=1539981.11..1540048.96 rows=1 width=44) (actual time=13484.068..13540.117 rows=10 loops=1) + Join Filter: (supplier.s_suppkey = partsupp.ps_suppkey) + Rows Removed by Join Filter: 803023 + -> Gather Merge (cost=3907.27..3967.22 rows=526 width=48) (actual time=137.383..137.477 rows=28 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2907.26..2908.04 rows=309 width=48) (actual time=70.375..70.378 rows=16 loops=2) + Sort Key: supplier.s_name NULLS FIRST + Sort Method: quicksort Memory: 398kB + Worker 0: Sort Method: quicksort Memory: 25kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=48) (actual time=59.860..68.517 rows=2027 loops=2) + Hash Cond: (supplier.s_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on supplier (cost=0.00..2724.24 rows=58824 width=52) (actual time=0.012..5.184 rows=50000 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=59.769..59.769 rows=1 loops=2) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation (cost=0.00..12.38 rows=1 width=4) (actual time=59.759..59.761 rows=1 loops=2) + Filter: ((n_name)::text = 'CANADA'::text) + Rows Removed by Filter: 24 + -> Materialize (cost=1536073.84..1536073.85 rows=1 width=4) (actual time=476.100..477.607 rows=28680 loops=28) + -> Group (cost=1536073.84..1536073.85 rows=1 width=4) (actual time=13330.797..13339.556 rows=44482 loops=1) + Group Key: partsupp.ps_suppkey + -> Sort (cost=1536073.84..1536073.85 rows=1 width=4) (actual time=13330.772..13333.465 rows=58655 loops=1) + Sort Key: partsupp.ps_suppkey + Sort Method: quicksort Memory: 1537kB + -> Nested Loop (cost=1488636.00..1536073.83 rows=1 width=4) (actual time=6329.565..13322.624 rows=58655 loops=1) + Join Filter: (partsupp.ps_partkey = part.p_partkey) + -> Merge Join (cost=1488635.57..1527328.48 rows=2962 width=44) (actual time=6329.519..13081.428 rows=58782 loops=1) + Merge Cond: (lineitem.l_partkey = part.p_partkey) + -> Finalize GroupAggregate (cost=1436559.92..1474389.00 rows=293289 width=40) (actual time=6189.232..12641.228 rows=5441655 loops=1) + Group Key: lineitem.l_partkey, lineitem.l_suppkey + -> Gather Merge (cost=1436559.92..1468223.31 rows=249958 width=40) (actual time=6189.222..8984.545 rows=7511297 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1435559.90..1438371.93 rows=124979 width=40) (actual time=6164.701..8055.440 rows=2503770 loops=3) + Group Key: lineitem.l_partkey, lineitem.l_suppkey + -> Sort (cost=1435559.90..1435872.35 rows=124979 width=13) (actual time=6164.668..6547.351 rows=3033053 loops=3) + Sort Key: lineitem.l_partkey, lineitem.l_suppkey + Sort Method: external merge Disk: 57648kB + Worker 0: Sort Method: external merge Disk: 91464kB + Worker 1: Sort Method: external merge Disk: 55864kB + -> Parallel Seq Scan on lineitem (cost=0.00..1422841.10 rows=124979 width=13) (actual time=98.674..4916.627 rows=3033055 loops=3) + Filter: (EXTRACT(year FROM (l_shipdate)::timestamp without time zone) = '1994'::numeric) + Rows Removed by Filter: 16962296 + -> Sort (cost=52075.64..52126.14 rows=20199 width=4) (actual time=140.211..142.064 rows=21551 loops=1) + Sort Key: part.p_partkey + Sort Method: quicksort Memory: 769kB + -> Gather (cost=1000.00..50631.21 rows=20199 width=4) (actual time=0.257..137.265 rows=21551 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on part (cost=0.00..47611.31 rows=8416 width=4) (actual time=50.268..123.837 rows=7184 loops=3) + Filter: ((p_name)::text ~~ 'forest%'::text) + Rows Removed by Filter: 659483 + -> Index Scan using partsupp_pkey on partsupp (cost=0.43..2.94 rows=1 width=12) (actual time=0.004..0.004 rows=1 loops=58782) + Index Cond: ((ps_partkey = lineitem.l_partkey) AND (ps_suppkey = lineitem.l_suppkey) AND (ps_suppkey IS NOT NULL)) + Filter: ((ps_availqty)::numeric > (0.5 * COALESCE((sum(lineitem.l_quantity)), '0'::numeric))) + Rows Removed by Filter: 0 +Planning Time: 0.629 ms +JIT: + Functions: 88 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.083 ms, Inlining 340.187 ms, Optimization 257.433 ms, Emission 186.470 ms, Total 788.173 ms +Execution Time: 13767.582 ms",SUCCESS +20,21,TPCH,Q21,"SELECT + s.s_name, + COUNT(*) AS numwait +FROM tpch.supplier s +JOIN tpch.lineitem l1 + ON s.s_suppkey = l1.l_suppkey +JOIN tpch.orders o + ON o.o_orderkey = l1.l_orderkey +JOIN tpch.nation n + ON s.s_nationkey = n.n_nationkey +WHERE o.o_orderstatus = 'F' + AND l1.l_receiptdate > l1.l_commitdate + AND EXISTS ( + SELECT 1 + FROM tpch.lineitem l2 + WHERE l2.l_orderkey = l1.l_orderkey + AND l2.l_suppkey <> l1.l_suppkey + ) + AND NOT EXISTS ( + SELECT 1 + FROM tpch.lineitem l3 + WHERE l3.l_orderkey = l1.l_orderkey + AND l3.l_suppkey <> l1.l_suppkey + AND l3.l_receiptdate > l3.l_commitdate + ) + AND n.n_name = 'SAUDI ARABIA' +GROUP BY s.s_name +ORDER BY numwait DESC, s.s_name +LIMIT 10;","date_check = receipt_date > commit_date +waiting_entries = ( + lines.CALCULATE(original_key=supplier_key) + .WHERE(date_check) + .order.WHERE( + (order_status == ""F"") + & HAS(lines.WHERE(supplier_key != original_key)) + & HASNOT(lines.WHERE((supplier_key != original_key) & date_check)) + ) +) +result = ( + suppliers.WHERE(nation.name == ""SAUDI ARABIA"") + .CALCULATE( + S_NAME=name, + NUMWAIT=COUNT(waiting_entries), + ) + .TOP_K( + 10, + by=(NUMWAIT.DESC(), S_NAME.ASC()), + ) +)","WITH _t5 AS ( + SELECT + l_commitdate, + l_linenumber, + l_orderkey, + l_receiptdate, + l_suppkey + FROM tpch.lineitem + WHERE + l_commitdate < l_receiptdate +), _t3 AS ( + SELECT + _t5.l_linenumber, + _t5.l_orderkey, + orders.o_orderkey, + MAX(_t5.l_suppkey) AS anything_l_suppkey, + MAX(orders.o_orderstatus) AS anything_o_orderstatus + FROM _t5 AS _t5 + JOIN tpch.orders AS orders + ON _t5.l_orderkey = orders.o_orderkey + JOIN tpch.lineitem AS lineitem + ON _t5.l_suppkey <> lineitem.l_suppkey AND lineitem.l_orderkey = orders.o_orderkey + GROUP BY + 1, + 2, + 3 +), _u_0 AS ( + SELECT + _t6.l_linenumber AS _u_1, + _t6.l_orderkey AS _u_2 + FROM _t5 AS _t6 + JOIN tpch.lineitem AS lineitem + ON _t6.l_orderkey = lineitem.l_orderkey + AND _t6.l_suppkey <> lineitem.l_suppkey + AND lineitem.l_commitdate < lineitem.l_receiptdate + GROUP BY + 1, + 2 +), _s11 AS ( + SELECT + _t3.anything_l_suppkey + FROM _t3 AS _t3 + LEFT JOIN _u_0 AS _u_0 + ON _t3.l_linenumber = _u_0._u_1 + AND _t3.l_orderkey = _u_0._u_2 + AND _t3.o_orderkey = _u_0._u_2 + WHERE + _t3.anything_o_orderstatus = 'F' AND _u_0._u_1 IS NULL +) +SELECT + MAX(supplier.s_name) AS S_NAME, + COUNT(_s11.anything_l_suppkey) AS NUMWAIT +FROM tpch.supplier AS supplier +JOIN tpch.nation AS nation + ON nation.n_name = 'SAUDI ARABIA' AND nation.n_nationkey = supplier.s_nationkey +LEFT JOIN _s11 AS _s11 + ON _s11.anything_l_suppkey = supplier.s_suppkey +GROUP BY + supplier.s_suppkey +ORDER BY + 2 DESC NULLS LAST, + 1 NULLS FIRST +LIMIT 10",6.193459202000213,254.20092595000006,"Limit (cost=1749433.74..1749433.74 rows=1 width=27) (actual time=6479.021..6479.301 rows=10 loops=1) + -> Sort (cost=1749433.74..1749433.74 rows=1 width=27) (actual time=6276.470..6276.748 rows=10 loops=1) + Sort Key: (count(*)) DESC, s.s_name + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=1749433.71..1749433.73 rows=1 width=27) (actual time=6271.180..6276.280 rows=4009 loops=1) + Group Key: s.s_name + -> Sort (cost=1749433.71..1749433.71 rows=1 width=19) (actual time=6271.147..6272.941 rows=39448 loops=1) + Sort Key: s.s_name + Sort Method: quicksort Memory: 2769kB + -> Nested Loop (cost=3899.91..1749433.70 rows=1 width=19) (actual time=232.910..6164.531 rows=39448 loops=1) + -> Nested Loop Semi Join (cost=3899.48..1749426.53 rows=1 width=27) (actual time=232.885..5662.015 rows=81045 loops=1) + -> Gather (cost=3898.91..1749214.53 rows=1 width=27) (actual time=232.871..4959.415 rows=135716 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Nested Loop Anti Join (cost=2898.91..1748214.43 rows=1 width=27) (actual time=218.956..5735.769 rows=45239 loops=3) + -> Parallel Hash Join (cost=2898.35..1332255.40 rows=42565 width=27) (actual time=218.827..4352.138 rows=507455 loops=3) + Hash Cond: (l1.l_suppkey = s.s_suppkey) + -> Parallel Seq Scan on lineitem l1 (cost=0.00..1297862.50 rows=8331907 width=8) (actual time=0.044..2701.626 rows=12643116 loops=3) + Filter: (l_receiptdate > l_commitdate) + Rows Removed by Filter: 7352235 + -> Parallel Hash (cost=2894.48..2894.48 rows=309 width=23) (actual time=218.546..218.548 rows=1337 loops=3) + Buckets: 4096 (originally 1024) Batches: 1 (originally 1) Memory Usage: 344kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=23) (actual time=139.245..147.622 rows=1337 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2724.24 rows=58824 width=27) (actual time=0.015..4.853 rows=33333 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=139.204..139.205 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n (cost=0.00..12.38 rows=1 width=4) (actual time=139.183..139.184 rows=1 loops=3) + Filter: ((n_name)::text = 'SAUDI ARABIA'::text) + Rows Removed by Filter: 24 + -> Index Scan using lineitem_pkey on lineitem l3 (cost=0.56..212.32 rows=45 width=8) (actual time=0.002..0.002 rows=1 loops=1522366) + Index Cond: (l_orderkey = l1.l_orderkey) + Filter: ((l_receiptdate > l_commitdate) AND (l_suppkey <> l1.l_suppkey)) + Rows Removed by Filter: 1 + -> Index Scan using lineitem_pkey on lineitem l2 (cost=0.56..211.98 rows=135 width=8) (actual time=0.005..0.005 rows=1 loops=135716) + Index Cond: (l_orderkey = l1.l_orderkey) + Filter: (l_suppkey <> l1.l_suppkey) + Rows Removed by Filter: 1 + -> Index Scan using orders_pkey on orders o (cost=0.43..7.17 rows=1 width=4) (actual time=0.006..0.006 rows=0 loops=81045) + Index Cond: (o_orderkey = l1.l_orderkey) + Filter: (o_orderstatus = 'F'::bpchar) + Rows Removed by Filter: 1 +Planning Time: 1.591 ms +JIT: + Functions: 105 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.416 ms, Inlining 118.354 ms, Optimization 299.574 ms, Emission 202.252 ms, Total 624.596 ms +Execution Time: 6480.912 ms","Limit (cost=58158477.78..58158477.81 rows=10 width=44) (actual time=293398.549..293398.558 rows=10 loops=1) + CTE _t5 + -> Seq Scan on lineitem lineitem_2 (cost=0.00..1735287.60 rows=19996576 width=20) (actual time=0.043..6963.077 rows=37929348 loops=1) + Filter: (l_commitdate < l_receiptdate) + Rows Removed by Filter: 22056704 + -> Sort (cost=56423190.18..56423191.50 rows=526 width=44) (actual time=293030.234..293030.242 rows=10 loops=1) + Sort Key: (count(_t3.anything_l_suppkey)) DESC NULLS LAST, (max((supplier.s_name)::text)) NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=56416907.59..56423178.82 rows=526 width=44) (actual time=292890.747..293029.442 rows=4010 loops=1) + Group Key: supplier.s_suppkey + -> Merge Left Join (cost=56416907.59..56423169.61 rows=526 width=27) (actual time=292890.666..293025.549 rows=39449 loops=1) + Merge Cond: (supplier.s_suppkey = _t3.anything_l_suppkey) + -> Nested Loop (cost=0.29..6260.12 rows=526 width=23) (actual time=0.077..31.217 rows=4010 loops=1) + Join Filter: (nation.n_nationkey = supplier.s_nationkey) + Rows Removed by Join Filter: 95990 + -> Index Scan using supplier_pkey on supplier (cost=0.29..4747.74 rows=100000 width=27) (actual time=0.017..11.703 rows=100000 loops=1) + -> Materialize (cost=0.00..12.38 rows=1 width=4) (actual time=0.000..0.000 rows=1 loops=100000) + -> Seq Scan on nation (cost=0.00..12.38 rows=1 width=4) (actual time=0.027..0.028 rows=1 loops=1) + Filter: ((n_name)::text = 'SAUDI ARABIA'::text) + Rows Removed by Filter: 24 + -> Sort (cost=56416907.30..56416907.73 rows=175 width=4) (actual time=292890.478..292949.039 rows=990375 loops=1) + Sort Key: _t3.anything_l_suppkey + Sort Method: external sort Disk: 15552kB + -> Hash Right Anti Join (cost=56415762.65..56416900.78 rows=175 width=4) (actual time=285053.137..292658.080 rows=990572 loops=1) + Hash Cond: ((_t6.l_linenumber = _t3.l_linenumber) AND (_t6.l_orderkey = _t3.l_orderkey) AND (_t6.l_orderkey = _t3.o_orderkey)) + -> HashAggregate (cost=21950009.02..21950409.02 rows=40000 width=8) (actual time=57582.628..92080.677 rows=34557064 loops=1) + Group Key: _t6.l_linenumber, _t6.l_orderkey + Batches: 1925 Memory Usage: 10033kB Disk Usage: 2747312kB + -> Hash Join (cost=2063356.80..17438921.71 rows=902217462 width=8) (actual time=11859.679..41457.286 rows=95916266 loops=1) + Hash Cond: (_t6.l_orderkey = lineitem.l_orderkey) + Join Filter: (_t6.l_suppkey <> lineitem.l_suppkey) + Rows Removed by Join Filter: 37930326 + -> CTE Scan on _t5 _t6 (cost=0.00..399931.52 rows=19996576 width=12) (actual time=0.329..7303.888 rows=37929348 loops=1) + -> Hash (cost=1735287.60..1735287.60 rows=19996576 width=8) (actual time=11852.164..11852.165 rows=37929348 loops=1) + Buckets: 262144 (originally 262144) Batches: 256 (originally 128) Memory Usage: 7825kB + -> Seq Scan on lineitem (cost=0.00..1735287.60 rows=19996576 width=8) (actual time=0.030..6958.885 rows=37929348 loops=1) + Filter: (l_commitdate < l_receiptdate) + Rows Removed by Filter: 22056704 + -> Hash (cost=34465750.13..34465750.13 rows=200 width=16) (actual time=187883.288..187883.292 rows=17654363 loops=1) + Buckets: 262144 (originally 1024) Batches: 256 (originally 1) Memory Usage: 6145kB + -> Subquery Scan on _t3 (cost=34465248.13..34465750.13 rows=200 width=16) (actual time=121842.381..184820.582 rows=17654363 loops=1) + -> HashAggregate (cost=34465248.13..34465748.13 rows=200 width=48) (actual time=121842.378..183408.264 rows=17654363 loops=1) + Group Key: _t5.l_linenumber, _t5.l_orderkey + Filter: (max(orders.o_orderstatus) = 'F'::bpchar) + Batches: 1029 Memory Usage: 8241kB Disk Usage: 5880584kB + Rows Removed by Filter: 18919625 + -> Hash Join (cost=3961052.76..7398724.26 rows=2706652387 width=18) (actual time=37098.818..89779.053 rows=151691143 loops=1) + Hash Cond: (_t5.l_orderkey = orders.o_orderkey) + Join Filter: (_t5.l_suppkey <> lineitem_1.l_suppkey) + Rows Removed by Join Filter: 37930892 + -> CTE Scan on _t5 (cost=0.00..399931.52 rows=19996576 width=12) (actual time=0.048..16977.666 rows=37929348 loops=1) + -> Hash (cost=2918262.16..2918262.16 rows=59989728 width=14) (actual time=36948.066..36948.068 rows=59986052 loops=1) + Buckets: 262144 Batches: 512 Memory Usage: 7555kB + -> Hash Join (cost=648219.80..2918262.16 rows=59989728 width=14) (actual time=3301.496..26977.606 rows=59986052 loops=1) + Hash Cond: (lineitem_1.l_orderkey = orders.o_orderkey) + -> Seq Scan on lineitem lineitem_1 (cost=0.00..1585313.28 rows=59989728 width=8) (actual time=0.008..6015.720 rows=59986052 loops=1) + -> Hash (cost=402161.69..402161.69 rows=14997769 width=6) (actual time=3291.793..3291.794 rows=15000000 loops=1) + Buckets: 262144 Batches: 128 Memory Usage: 6391kB + -> Seq Scan on orders (cost=0.00..402161.69 rows=14997769 width=6) (actual time=0.046..1499.117 rows=15000000 loops=1) +Planning Time: 2.752 ms +JIT: + Functions: 80 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 11.651 ms, Inlining 70.148 ms, Optimization 228.509 ms, Emission 155.521 ms, Total 465.829 ms +Execution Time: 293765.123 ms",SUCCESS +21,22,TPCH,Q22,"SELECT + cntrycode, + COUNT(*) AS numcust, + SUM(c_acctbal) AS totacctbal +FROM ( + SELECT + SUBSTRING(c.c_phone FROM 1 FOR 2) AS cntrycode, + c.c_acctbal + FROM tpch.customer c + WHERE SUBSTRING(c.c_phone FROM 1 FOR 2) IN + ('13', '31', '23', '29', '30', '18', '17') + AND c.c_acctbal > ( + SELECT AVG(c2.c_acctbal) + FROM tpch.customer c2 + WHERE c2.c_acctbal > 0.00 + AND SUBSTRING(c2.c_phone FROM 1 FOR 2) IN + ('13', '31', '23', '29', '30', '18', '17') + ) + AND NOT EXISTS ( + SELECT 1 + FROM tpch.orders o + WHERE o.o_custkey = c.c_custkey + ) +) AS custsale +GROUP BY cntrycode +ORDER BY cntrycode;","is_selected_code = ISIN(cntry_code, (""13"", ""31"", ""23"", ""29"", ""30"", ""18"", ""17"")) +selected_customers = customers.CALCULATE(cntry_code=phone[:2]).WHERE( + is_selected_code +) +result = ( + TPCH.CALCULATE( + global_avg_balance=AVG( + selected_customers.WHERE(account_balance > 0.0).account_balance + ) + ) + .customers.CALCULATE(cntry_code=phone[:2]) + .WHERE( + is_selected_code & (account_balance > global_avg_balance) & HASNOT(orders) + ) + .PARTITION( + name=""countries"", + by=cntry_code, + ) + .CALCULATE( + CNTRYCODE=cntry_code, + NUMCUST=COUNT(customers), + TOTACCTBAL=SUM(customers.account_balance), + ) + .ORDER_BY(CNTRYCODE.ASC()) +)","WITH _s0 AS ( + SELECT + AVG(CAST(c_acctbal AS DECIMAL)) AS avg_c_acctbal + FROM tpch.customer + WHERE + SUBSTRING(c_phone FROM 1 FOR 2) IN ('13', '31', '23', '29', '30', '18', '17') + AND c_acctbal > 0.0 +), _u_0 AS ( + SELECT + o_custkey AS _u_1 + FROM tpch.orders + GROUP BY + 1 +) +SELECT + SUBSTRING(customer.c_phone FROM 1 FOR 2) AS CNTRYCODE, + COUNT(*) AS NUMCUST, + COALESCE(SUM(customer.c_acctbal), 0) AS TOTACCTBAL +FROM _s0 AS _s0 +JOIN tpch.customer AS customer + ON SUBSTRING(customer.c_phone FROM 1 FOR 2) IN ('13', '31', '23', '29', '30', '18', '17') + AND _s0.avg_c_acctbal < customer.c_acctbal +LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = customer.c_custkey +WHERE + _u_0._u_1 IS NULL +GROUP BY + 1 +ORDER BY + 1 NULLS FIRST",1.719703146000029,4.82431747299961,"Finalize GroupAggregate (cost=474110.99..475092.08 rows=7551 width=72) (actual time=1718.948..1726.150 rows=7 loops=1) + Group Key: (SUBSTRING(c.c_phone FROM 1 FOR 2)) + InitPlan 1 (returns $1) + -> Finalize Aggregate (cost=51638.58..51638.59 rows=1 width=32) (actual time=233.543..233.699 rows=1 loops=1) + -> Gather (cost=51638.36..51638.57 rows=2 width=32) (actual time=233.379..233.667 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=50638.36..50638.37 rows=1 width=32) (actual time=217.417..217.418 rows=1 loops=3) + -> Parallel Seq Scan on customer c2 (cost=0.00..50588.71 rows=19860 width=6) (actual time=7.808..204.088 rows=127259 loops=3) + Filter: ((c_acctbal > 0.00) AND (SUBSTRING(c_phone FROM 1 FOR 2) = ANY ('{13,31,23,29,30,18,17}'::text[]))) + Rows Removed by Filter: 372741 + -> Gather Merge (cost=422472.40..423277.30 rows=6292 width=72) (actual time=1718.916..1725.955 rows=7 loops=1) + Workers Planned: 2 + Params Evaluated: $1 + Workers Launched: 2 + -> Partial GroupAggregate (cost=421472.37..421551.02 rows=3146 width=72) (actual time=1440.552..1443.706 rows=2 loops=3) + Group Key: (SUBSTRING(c.c_phone FROM 1 FOR 2)) + -> Sort (cost=421472.37..421480.24 rows=3146 width=38) (actual time=1440.054..1441.165 rows=21305 loops=3) + Sort Key: (SUBSTRING(c.c_phone FROM 1 FOR 2)) + Sort Method: quicksort Memory: 25kB + Worker 0: Sort Method: quicksort Memory: 4028kB + Worker 1: Sort Method: quicksort Memory: 25kB + -> Parallel Hash Right Anti Join (cost=50679.86..421289.60 rows=3146 width=38) (actual time=1431.342..1435.946 rows=21305 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..314674.70 rows=6249070 width=4) (actual time=0.019..508.851 rows=5000000 loops=3) + -> Parallel Hash (cost=50588.71..50588.71 rows=7292 width=26) (actual time=196.916..196.916 rows=63564 loops=3) + Buckets: 262144 (originally 32768) Batches: 1 (originally 1) Memory Usage: 15840kB + -> Parallel Seq Scan on customer c (cost=0.00..50588.71 rows=7292 width=26) (actual time=6.570..174.176 rows=63564 loops=3) + Filter: ((c_acctbal > $1) AND (SUBSTRING(c_phone FROM 1 FOR 2) = ANY ('{13,31,23,29,30,18,17}'::text[]))) + Rows Removed by Filter: 436436 +Planning Time: 0.226 ms +JIT: + Functions: 71 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 4.219 ms, Inlining 0.000 ms, Optimization 2.198 ms, Emission 40.944 ms, Total 47.361 ms +Execution Time: 1727.487 ms","GroupAggregate (cost=1104689.70..1104908.45 rows=8750 width=72) (actual time=4983.343..4992.166 rows=7 loops=1) + Group Key: (SUBSTRING(customer.c_phone FROM 1 FOR 2)) + -> Sort (cost=1104689.70..1104711.57 rows=8750 width=38) (actual time=4981.898..4984.784 rows=63914 loops=1) + Sort Key: (SUBSTRING(customer.c_phone FROM 1 FOR 2)) NULLS FIRST + Sort Method: quicksort Memory: 4028kB + -> Hash Right Anti Join (cost=1078943.80..1104116.79 rows=8750 width=38) (actual time=4910.035..4971.278 rows=63914 loops=1) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Finalize HashAggregate (cost=971153.74..993007.28 rows=852821 width=4) (actual time=3632.790..4100.077 rows=999982 loops=1) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 81 Memory Usage: 9361kB Disk Usage: 64464kB + -> Gather (cost=651562.22..879475.49 rows=1705642 width=4) (actual time=2190.402..3104.754 rows=2931584 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=650562.22..707911.29 rows=852821 width=4) (actual time=2174.465..3052.430 rows=977195 loops=3) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 81 Memory Usage: 10641kB Disk Usage: 129168kB + Worker 0: Batches: 81 Memory Usage: 10385kB Disk Usage: 113544kB + Worker 1: Batches: 81 Memory Usage: 10641kB Disk Usage: 178904kB + -> Parallel Seq Scan on orders (cost=0.00..314674.70 rows=6249070 width=4) (actual time=0.021..513.877 rows=5000000 loops=3) + -> Hash (cost=107571.29..107571.29 rows=17501 width=26) (actual time=690.026..690.123 rows=190691 loops=1) + Buckets: 131072 (originally 32768) Batches: 2 (originally 1) Memory Usage: 7169kB + -> Nested Loop (cost=52638.58..107571.29 rows=17501 width=26) (actual time=375.710..661.001 rows=190691 loops=1) + Join Filter: ((avg((customer_1.c_acctbal)::numeric)) < customer.c_acctbal) + Rows Removed by Join Filter: 229283 + -> Finalize Aggregate (cost=51638.58..51638.59 rows=1 width=32) (actual time=375.392..375.439 rows=1 loops=1) + -> Gather (cost=51638.36..51638.57 rows=2 width=32) (actual time=375.254..375.407 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=50638.36..50638.37 rows=1 width=32) (actual time=362.379..362.379 rows=1 loops=3) + -> Parallel Seq Scan on customer customer_1 (cost=0.00..50588.71 rows=19860 width=6) (actual time=172.543..349.999 rows=127259 loops=3) + Filter: ((c_acctbal > 0.0) AND (SUBSTRING(c_phone FROM 1 FOR 2) = ANY ('{13,31,23,29,30,18,17}'::text[]))) + Rows Removed by Filter: 372741 + -> Gather (cost=1000.00..55276.41 rows=52503 width=26) (actual time=0.309..244.787 rows=419974 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on customer (cost=0.00..49026.11 rows=21876 width=26) (actual time=73.761..248.907 rows=139991 loops=3) + Filter: (SUBSTRING(c_phone FROM 1 FOR 2) = ANY ('{13,31,23,29,30,18,17}'::text[])) + Rows Removed by Filter: 360009 +Planning Time: 0.206 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.034 ms, Inlining 435.211 ms, Optimization 286.158 ms, Emission 213.101 ms, Total 938.504 ms +Execution Time: 5018.838 ms",SUCCESS +22,23,TPCDS,Q1,"WITH customer_total_return AS ( + SELECT + sr_customer_sk AS ctr_customer_sk, + sr_store_sk AS ctr_store_sk, + SUM(sr_return_amt) AS ctr_total_return + FROM tpcds.store_returns + JOIN tpcds.date_dim ON sr_returned_date_sk = d_date_sk AND d_year = 2000 + GROUP BY sr_customer_sk, sr_store_sk +), +store_avg AS ( + SELECT + ctr_store_sk, + AVG(ctr_total_return) * 1.2 AS avg_return_threshold + FROM customer_total_return + GROUP BY ctr_store_sk +) +SELECT c_customer_id +FROM customer_total_return ctr1 +JOIN tpcds.store ON s_store_sk = ctr1.ctr_store_sk AND s_state = 'TN' +JOIN tpcds.customer ON ctr1.ctr_customer_sk = c_customer_sk +JOIN store_avg ON ctr1.ctr_store_sk = store_avg.ctr_store_sk +WHERE ctr1.ctr_total_return > store_avg.avg_return_threshold +ORDER BY c_customer_id +LIMIT 10;","result = (store_returns.WHERE( + (store.state == ""TN"") & (returned_date.year == 2000) +).PARTITION( + name=""store_customer_groups"", + by=(customer_key, store_key) +).CALCULATE( + customer_total=SUM(store_returns.amount) +).PARTITION( + name=""store_groups"", by=store_key +).CALCULATE( + store_avg=1.2 * AVG(store_customer_groups.customer_total) +).store_customer_groups.WHERE( + customer_total > store_avg +).store_returns.customer.CALCULATE( + c_customer_id=_id +).TOP_K(10, by=c_customer_id))","WITH _s0 AS ( + SELECT + sr_customer_sk, + sr_return_amt, + sr_returned_date_sk, + sr_store_sk + FROM tpcds.store_returns +), _t3 AS ( + SELECT + s_state, + s_store_sk + FROM tpcds.store + WHERE + s_state = 'TN' +), _t4 AS ( + SELECT + d_date_sk, + d_year + FROM tpcds.date_dim + WHERE + d_year = 2000 +), _t1 AS ( + SELECT + _s0.sr_store_sk, + SUM(_s0.sr_return_amt) AS sum_sr_return_amt + FROM _s0 AS _s0 + JOIN _t3 AS _t3 + ON _s0.sr_store_sk = _t3.s_store_sk + JOIN _t4 AS _t4 + ON _s0.sr_returned_date_sk = _t4.d_date_sk + GROUP BY + _s0.sr_customer_sk, + 1 +), _s8 AS ( + SELECT + sr_store_sk, + AVG(CAST(COALESCE(sum_sr_return_amt, 0) AS DECIMAL)) AS avg_customer_total + FROM _t1 + GROUP BY + 1 +), _s9 AS ( + SELECT + _s4.sr_customer_sk, + _s4.sr_store_sk, + SUM(_s4.sr_return_amt) AS sum_sr_return_amt + FROM _s0 AS _s4 + JOIN _t3 AS _t6 + ON _s4.sr_store_sk = _t6.s_store_sk + JOIN _t4 AS _t7 + ON _s4.sr_returned_date_sk = _t7.d_date_sk + GROUP BY + 1, + 2 +) +SELECT + customer.c_customer_id +FROM _s8 AS _s8 +JOIN _s9 AS _s9 + ON ( + 1.2 * _s8.avg_customer_total + ) < COALESCE(_s9.sum_sr_return_amt, 0) + AND _s8.sr_store_sk = _s9.sr_store_sk +JOIN tpcds.store_returns AS store_returns + ON _s9.sr_customer_sk = store_returns.sr_customer_sk + AND _s9.sr_store_sk = store_returns.sr_store_sk +JOIN _t3 AS _t8 + ON _t8.s_store_sk = store_returns.sr_store_sk +JOIN _t4 AS _t9 + ON _t9.d_date_sk = store_returns.sr_returned_date_sk +JOIN tpcds.customer AS customer + ON customer.c_customer_sk = store_returns.sr_customer_sk +ORDER BY + 1 NULLS FIRST +LIMIT 10",2.0637868610001533,4.544565095000053,"Limit (cost=115446.28..115446.31 rows=10 width=17) (actual time=1404.273..1404.565 rows=10 loops=1) + CTE customer_total_return + -> Finalize GroupAggregate (cost=83005.02..84759.00 rows=13878 width=48) (actual time=324.027..817.245 rows=539331 loops=1) + Group Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + -> Gather Merge (cost=83005.02..84469.88 rows=11564 width=48) (actual time=324.008..516.737 rows=543151 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=82004.99..82135.09 rows=5782 width=48) (actual time=307.910..435.243 rows=181050 loops=3) + Group Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + -> Sort (cost=82004.99..82019.45 rows=5782 width=22) (actual time=307.877..329.239 rows=185902 loops=3) + Sort Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + Sort Method: external merge Disk: 5440kB + Worker 0: Sort Method: external merge Disk: 4984kB + Worker 1: Sort Method: external merge Disk: 7336kB + -> Parallel Hash Join (cost=2571.81..81643.69 rows=5782 width=22) (actual time=9.323..246.850 rows=185902 loops=3) + Hash Cond: (store_returns.sr_returned_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_returns (cost=0.00..74541.69 rows=1198969 width=30) (actual time=0.019..110.111 rows=959177 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=3.018..3.018 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=4.462..8.937 rows=366 loops=1) + Filter: (d_year = 2000) + Rows Removed by Filter: 72683 + -> Sort (cost=30687.29..30689.08 rows=717 width=17) (actual time=1384.873..1384.876 rows=10 loops=1) + Sort Key: customer.c_customer_id + Sort Method: top-N heapsort Memory: 25kB + -> Hash Join (cost=26899.11..30671.79 rows=717 width=17) (actual time=1185.350..1376.412 rows=45702 loops=1) + Hash Cond: (ctr1.ctr_customer_sk = customer.c_customer_sk) + -> Hash Join (cost=359.11..697.93 rows=717 width=8) (actual time=1056.423..1210.116 rows=45719 loops=1) + Hash Cond: (ctr1.ctr_store_sk = store.s_store_sk) + -> Hash Join (cost=352.45..666.75 rows=4626 width=24) (actual time=1056.353..1197.342 rows=137685 loops=1) + Hash Cond: (ctr1.ctr_store_sk = customer_total_return.ctr_store_sk) + Join Filter: (ctr1.ctr_total_return > ((avg(customer_total_return.ctr_total_return) * 1.2))) + Rows Removed by Join Filter: 396509 + -> CTE Scan on customer_total_return ctr1 (cost=0.00..277.56 rows=13878 width=48) (actual time=324.029..363.457 rows=539331 loops=1) + -> Hash (cost=349.95..349.95 rows=200 width=40) (actual time=732.290..732.291 rows=51 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 11kB + -> HashAggregate (cost=346.95..349.95 rows=200 width=40) (actual time=732.253..732.277 rows=52 loops=1) + Group Key: customer_total_return.ctr_store_sk + Batches: 1 Memory Usage: 64kB + -> CTE Scan on customer_total_return (cost=0.00..277.56 rows=13878 width=40) (actual time=0.001..624.902 rows=539331 loops=1) + -> Hash (cost=6.28..6.28 rows=31 width=8) (actual time=0.059..0.059 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on store (cost=0.00..6.28 rows=31 width=8) (actual time=0.014..0.053 rows=31 loops=1) + Filter: ((s_state)::text = 'TN'::text) + Rows Removed by Filter: 71 + -> Hash (cost=16872.00..16872.00 rows=500000 width=25) (actual time=128.624..128.625 rows=500000 loops=1) + Buckets: 131072 Batches: 8 Memory Usage: 4929kB + -> Seq Scan on customer (cost=0.00..16872.00 rows=500000 width=25) (actual time=0.017..57.407 rows=500000 loops=1) +Planning Time: 0.282 ms +JIT: + Functions: 90 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.769 ms, Inlining 0.000 ms, Optimization 1.666 ms, Emission 36.277 ms, Total 41.713 ms +Execution Time: 1409.475 ms","Limit (cost=583093.57..583093.59 rows=10 width=17) (actual time=5906.912..5906.928 rows=10 loops=1) + CTE _s0 + -> Seq Scan on store_returns store_returns_1 (cost=0.00..91327.25 rows=2877525 width=30) (actual time=0.010..362.814 rows=2877532 loops=1) + CTE _t3 + -> Seq Scan on store (cost=0.00..6.28 rows=31 width=11) (actual time=0.012..0.041 rows=31 loops=1) + Filter: ((s_state)::text = 'TN'::text) + Rows Removed by Filter: 71 + CTE _t4 + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=365 width=16) (actual time=2.449..4.942 rows=366 loops=1) + Filter: (d_year = 2000) + Rows Removed by Filter: 72683 + -> Sort (cost=488814.93..488814.97 rows=14 width=17) (actual time=5293.583..5293.596 rows=10 loops=1) + Sort Key: customer.c_customer_id NULLS FIRST + Sort Method: top-N heapsort Memory: 25kB + -> Hash Join (cost=470067.52..488814.66 rows=14 width=17) (actual time=5186.862..5284.301 rows=47280 loops=1) + Hash Cond: (customer.c_customer_sk = _s9.sr_customer_sk) + -> Seq Scan on customer (cost=0.00..16872.00 rows=500000 width=25) (actual time=0.021..46.419 rows=500000 loops=1) + -> Hash (cost=470067.35..470067.35 rows=14 width=16) (actual time=5186.804..5186.816 rows=47280 loops=1) + Buckets: 65536 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2729kB + -> Nested Loop (cost=362941.63..470067.35 rows=14 width=16) (actual time=3656.966..5181.176 rows=47280 loops=1) + Join Filter: (store_returns.sr_returned_date_sk = _t9.d_date_sk) + Rows Removed by Join Filter: 18745356 + -> CTE Scan on _t4 _t9 (cost=0.00..7.30 rows=365 width=8) (actual time=2.452..2.516 rows=366 loops=1) + -> Materialize (cost=362941.63..469622.25 rows=80 width=24) (actual time=9.985..12.198 rows=51346 loops=366) + -> Nested Loop (cost=362941.63..469621.85 rows=80 width=24) (actual time=3654.312..3770.673 rows=51346 loops=1) + Join Filter: (_s8.sr_store_sk = _t8.s_store_sk) + Rows Removed by Join Filter: 1540380 + -> CTE Scan on _t3 _t8 (cost=0.00..0.62 rows=31 width=8) (actual time=0.013..0.022 rows=31 loops=1) + -> Materialize (cost=362941.63..469382.58 rows=516 width=48) (actual time=75.636..119.616 rows=51346 loops=31) + -> Hash Join (cost=362941.63..469380.00 rows=516 width=48) (actual time=2344.714..3637.125 rows=51346 loops=1) + Hash Cond: (_s9.sr_store_sk = _s8.sr_store_sk) + Join Filter: ((1.2 * _s8.avg_customer_total) < COALESCE(_s9.sum_sr_return_amt, '0'::numeric)) + Rows Removed by Join Filter: 144646 + -> Hash Join (cost=181667.32..288101.57 rows=1547 width=72) (actual time=760.546..1995.847 rows=195992 loops=1) + Hash Cond: ((store_returns.sr_store_sk = _s9.sr_store_sk) AND (store_returns.sr_customer_sk = _s9.sr_customer_sk)) + -> Seq Scan on store_returns (cost=0.00..91327.25 rows=2877525 width=24) (actual time=0.012..264.385 rows=2877532 loops=1) + -> Hash (cost=181067.32..181067.32 rows=40000 width=48) (actual time=760.451..760.456 rows=177510 loops=1) + Buckets: 262144 (originally 65536) Batches: 2 (originally 1) Memory Usage: 7165kB + -> Subquery Scan on _s9 (cost=169038.70..181067.32 rows=40000 width=48) (actual time=609.160..732.602 rows=177527 loops=1) + -> HashAggregate (cost=169038.70..180667.32 rows=40000 width=48) (actual time=609.155..720.409 rows=177527 loops=1) + Group Key: _s4.sr_customer_sk, _s4.sr_store_sk + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 7624kB + -> Hash Join (cost=12.87..102139.80 rows=813979 width=30) (actual time=0.121..557.422 rows=181937 loops=1) + Hash Cond: (_s4.sr_returned_date_sk = _t7.d_date_sk) + -> Hash Join (cost=1.01..72802.39 rows=446016 width=38) (actual time=0.038..479.483 rows=924363 loops=1) + Hash Cond: (_s4.sr_store_sk = _t6.s_store_sk) + -> CTE Scan on _s0 _s4 (cost=0.00..57550.50 rows=2877525 width=38) (actual time=0.017..206.605 rows=2877532 loops=1) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=0.012..0.013 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 _t6 (cost=0.00..0.62 rows=31 width=8) (actual time=0.004..0.007 rows=31 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=0.074..0.075 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 _t7 (cost=0.00..7.30 rows=365 width=8) (actual time=0.003..0.039 rows=366 loops=1) + -> Hash (cost=181271.82..181271.82 rows=200 width=40) (actual time=1584.154..1584.158 rows=17 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Subquery Scan on _s8 (cost=181267.32..181271.82 rows=200 width=40) (actual time=1584.139..1584.150 rows=17 loops=1) + -> HashAggregate (cost=181267.32..181269.82 rows=200 width=40) (actual time=1584.135..1584.145 rows=17 loops=1) + Group Key: _s0.sr_store_sk + Batches: 1 Memory Usage: 40kB + -> HashAggregate (cost=169038.70..180667.32 rows=40000 width=48) (actual time=1454.396..1564.225 rows=177527 loops=1) + Group Key: _s0.sr_customer_sk, _s0.sr_store_sk + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 7624kB + -> Hash Join (cost=12.87..102139.80 rows=813979 width=30) (actual time=2.676..1397.207 rows=181937 loops=1) + Hash Cond: (_s0.sr_returned_date_sk = _t4.d_date_sk) + -> Hash Join (cost=1.01..72802.39 rows=446016 width=38) (actual time=0.074..1304.473 rows=924363 loops=1) + Hash Cond: (_s0.sr_store_sk = _t3.s_store_sk) + -> CTE Scan on _s0 (cost=0.00..57550.50 rows=2877525 width=38) (actual time=0.011..1035.614 rows=2877532 loops=1) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=0.045..0.045 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 (cost=0.00..0.62 rows=31 width=8) (actual time=0.003..0.038 rows=31 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=2.592..2.592 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 (cost=0.00..7.30 rows=365 width=8) (actual time=0.002..2.557 rows=366 loops=1) +Planning Time: 1.161 ms +JIT: + Functions: 103 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.431 ms, Inlining 28.015 ms, Optimization 386.861 ms, Emission 260.731 ms, Total 679.039 ms +Execution Time: 5927.983 ms",SUCCESS +23,24,TPCDS,Q2,"WITH wscs AS ( + SELECT sold_date_sk, sales_price + FROM ( + SELECT ws_sold_date_sk AS sold_date_sk, ws_ext_sales_price AS sales_price + FROM tpcds.web_sales + UNION ALL + SELECT cs_sold_date_sk AS sold_date_sk, cs_ext_sales_price AS sales_price + FROM tpcds.catalog_sales + ) x +), +wswscs AS ( + SELECT + d_week_seq, + SUM(CASE WHEN d_day_name = 'Sunday' THEN sales_price END) AS sun_sales, + SUM(CASE WHEN d_day_name = 'Monday' THEN sales_price END) AS mon_sales, + SUM(CASE WHEN d_day_name = 'Tuesday' THEN sales_price END) AS tue_sales, + SUM(CASE WHEN d_day_name = 'Wednesday' THEN sales_price END) AS wed_sales, + SUM(CASE WHEN d_day_name = 'Thursday' THEN sales_price END) AS thu_sales, + SUM(CASE WHEN d_day_name = 'Friday' THEN sales_price END) AS fri_sales, + SUM(CASE WHEN d_day_name = 'Saturday' THEN sales_price END) AS sat_sales + FROM wscs + JOIN tpcds.date_dim ON d_date_sk = sold_date_sk + GROUP BY d_week_seq +) +SELECT + d_week_seq1, + ROUND(sun_sales1 / NULLIF(sun_sales2, 0), 2) AS sunday_ratio, + ROUND(mon_sales1 / NULLIF(mon_sales2, 0), 2) AS monday_ratio, + ROUND(tue_sales1 / NULLIF(tue_sales2, 0), 2) AS tuesday_ratio, + ROUND(wed_sales1 / NULLIF(wed_sales2, 0), 2) AS wednesday_ratio, + ROUND(thu_sales1 / NULLIF(thu_sales2, 0), 2) AS thursday_ratio, + ROUND(fri_sales1 / NULLIF(fri_sales2, 0), 2) AS friday_ratio, + ROUND(sat_sales1 / NULLIF(sat_sales2, 0), 2) AS saturday_ratio +FROM ( + SELECT + wswscs.d_week_seq AS d_week_seq1, + sun_sales AS sun_sales1, mon_sales AS mon_sales1, + tue_sales AS tue_sales1, wed_sales AS wed_sales1, + thu_sales AS thu_sales1, fri_sales AS fri_sales1, + sat_sales AS sat_sales1, + ROW_NUMBER() OVER (PARTITION BY wswscs.d_week_seq ORDER BY sun_sales DESC) AS rn1 + FROM wswscs + JOIN tpcds.date_dim ON date_dim.d_week_seq = wswscs.d_week_seq + WHERE d_year = 2001 +) y +JOIN ( + SELECT + wswscs.d_week_seq AS d_week_seq2, + sun_sales AS sun_sales2, mon_sales AS mon_sales2, + tue_sales AS tue_sales2, wed_sales AS wed_sales2, + thu_sales AS thu_sales2, fri_sales AS fri_sales2, + sat_sales AS sat_sales2, + ROW_NUMBER() OVER (PARTITION BY wswscs.d_week_seq ORDER BY sun_sales DESC) AS rn2 + FROM wswscs + JOIN tpcds.date_dim ON date_dim.d_week_seq = wswscs.d_week_seq + WHERE d_year = 2001 + 1 +) z ON d_week_seq1 = d_week_seq2 - 53 WHERE rn1 = 1 and rn2 = 1 +ORDER BY d_week_seq1 LIMIT 10;","ct_sales = dates.CALCULATE(day_name).catalog_sales_by_sold_date +wb_sales = dates.CALCULATE(day_name).web_sales_by_sold_date + +week_breakdown = dates.WHERE(MONOTONIC(2000, year, 2003)).PARTITION( + name='week', by=(week_seq) +).CALCULATE( + sunday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Sunday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Sunday')), + monday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Monday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Monday')), + tuesday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Tuesday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Tuesday')), + wednesday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Wednesday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Wednesday')), + thursday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Thursday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Thursday')), + friday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Friday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Friday')), + saturday_amount=SUM(KEEP_IF(ct_sales.ext_sales_price, ct_sales.day_name == 'Saturday')) + SUM(KEEP_IF(wb_sales.ext_sales_price, wb_sales.day_name == 'Saturday')) +) + +week_breakdown_2001 = week_breakdown.WHERE(HAS(dates.WHERE(year == 2001))).CALCULATE( + week_seq_2001=week_seq, + sunday_amount_2001=sunday_amount, + monday_amount_2001=monday_amount, + tuesday_amount_2001=tuesday_amount, + wednesday_amount_2001=wednesday_amount, + thursday_amount_2001=thursday_amount, + friday_amount_2001=friday_amount, + saturday_amount_2001=saturday_amount +) + +week_breakdown_2002 = week_breakdown.WHERE(HAS(dates.WHERE(year == 2002))).CALCULATE( + week_seq_2002=week_seq, + sunday_amount_2002=sunday_amount, + monday_amount_2002=monday_amount, + tuesday_amount_2002=tuesday_amount, + wednesday_amount_2002=wednesday_amount, + thursday_amount_2002=thursday_amount, + friday_amount_2002=friday_amount, + saturday_amount_2002=saturday_amount +) + +result = week_breakdown_2001.CROSS(week_breakdown_2002).WHERE(week_seq_2002 == (week_seq_2001 + 53)).CALCULATE( + d_week_seq1=week_seq_2001, + sunday_ratio=ROUND(sunday_amount_2001 / KEEP_IF(sunday_amount_2002, sunday_amount_2002 != 0), 2), + monday_ratio=ROUND(monday_amount_2001 / KEEP_IF(monday_amount_2002, monday_amount_2002 != 0), 2), + tuesday_ratio=ROUND(tuesday_amount_2001 / KEEP_IF(tuesday_amount_2002, tuesday_amount_2002 != 0), 2), + wednesday_ratio=ROUND(wednesday_amount_2001 / KEEP_IF(wednesday_amount_2002, wednesday_amount_2002 != 0), 2), + thursday_ratio=ROUND(thursday_amount_2001 / KEEP_IF(thursday_amount_2002, thursday_amount_2002 != 0), 2), + friday_ratio=ROUND(friday_amount_2001 / KEEP_IF(friday_amount_2002, friday_amount_2002 != 0), 2), + saturday_ratio=ROUND(saturday_amount_2001 / KEEP_IF(saturday_amount_2002, saturday_amount_2002 != 0), 2) +).TOP_K(10, by=d_week_seq1)","WITH _t1 AS ( + SELECT + d_week_seq, + d_year + FROM tpcds.date_dim + WHERE + d_year <= 2003 AND d_year >= 2000 +), _s2 AS ( + SELECT DISTINCT + d_week_seq + FROM _t1 +), _t3 AS ( + SELECT + d_date_sk, + d_day_name, + d_week_seq, + d_year + FROM tpcds.date_dim + WHERE + d_year <= 2003 AND d_year >= 2000 +), _s1 AS ( + SELECT + cs_ext_sales_price, + cs_sold_date_sk + FROM tpcds.catalog_sales +), _s3 AS ( + SELECT + _t3.d_week_seq, + SUM(CASE WHEN _t3.d_day_name = 'Friday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr, + SUM(CASE WHEN _t3.d_day_name = 'Tuesday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_29, + SUM(CASE WHEN _t3.d_day_name = 'Wednesday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_30, + SUM(CASE WHEN _t3.d_day_name = 'Monday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_31, + SUM(CASE WHEN _t3.d_day_name = 'Saturday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_32, + SUM(CASE WHEN _t3.d_day_name = 'Sunday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_33, + SUM(CASE WHEN _t3.d_day_name = 'Thursday' THEN _s1.cs_ext_sales_price ELSE NULL END) AS sum_expr_34 + FROM _t3 AS _t3 + JOIN _s1 AS _s1 + ON _s1.cs_sold_date_sk = _t3.d_date_sk + GROUP BY + 1 +), _s5 AS ( + SELECT + ws_ext_sales_price, + ws_sold_date_sk + FROM tpcds.web_sales +), _s7 AS ( + SELECT + _t5.d_week_seq, + SUM(CASE WHEN _t5.d_day_name = 'Friday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr, + SUM(CASE WHEN _t5.d_day_name = 'Tuesday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_36, + SUM(CASE WHEN _t5.d_day_name = 'Wednesday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_37, + SUM(CASE WHEN _t5.d_day_name = 'Monday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_38, + SUM(CASE WHEN _t5.d_day_name = 'Saturday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_39, + SUM(CASE WHEN _t5.d_day_name = 'Sunday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_40, + SUM(CASE WHEN _t5.d_day_name = 'Thursday' THEN _s5.ws_ext_sales_price ELSE NULL END) AS sum_expr_41 + FROM _t3 AS _t5 + JOIN _s5 AS _s5 + ON _s5.ws_sold_date_sk = _t5.d_date_sk + GROUP BY + 1 +), _u_0 AS ( + SELECT + d_week_seq AS _u_1 + FROM tpcds.date_dim + WHERE + d_year = 2001 + GROUP BY + 1 +), _s11 AS ( + SELECT DISTINCT + d_week_seq + FROM _t1 +), _s15 AS ( + SELECT + _t9.d_week_seq, + SUM(CASE WHEN _t9.d_day_name = 'Friday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr, + SUM(CASE WHEN _t9.d_day_name = 'Monday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr_43, + SUM(CASE WHEN _t9.d_day_name = 'Saturday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr_44, + SUM(CASE WHEN _t9.d_day_name = 'Sunday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr_45, + SUM(CASE WHEN _t9.d_day_name = 'Thursday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr_46, + SUM(CASE WHEN _t9.d_day_name = 'Tuesday' THEN _s13.cs_ext_sales_price ELSE NULL END) AS sum_expr_47, + SUM( + CASE WHEN _t9.d_day_name = 'Wednesday' THEN _s13.cs_ext_sales_price ELSE NULL END + ) AS sum_expr_48 + FROM _t3 AS _t9 + JOIN _s1 AS _s13 + ON _s13.cs_sold_date_sk = _t9.d_date_sk + GROUP BY + 1 +), _s19 AS ( + SELECT + _t11.d_week_seq, + SUM(CASE WHEN _t11.d_day_name = 'Friday' THEN _s17.ws_ext_sales_price ELSE NULL END) AS sum_expr, + SUM(CASE WHEN _t11.d_day_name = 'Monday' THEN _s17.ws_ext_sales_price ELSE NULL END) AS sum_expr_50, + SUM( + CASE WHEN _t11.d_day_name = 'Saturday' THEN _s17.ws_ext_sales_price ELSE NULL END + ) AS sum_expr_51, + SUM(CASE WHEN _t11.d_day_name = 'Sunday' THEN _s17.ws_ext_sales_price ELSE NULL END) AS sum_expr_52, + SUM( + CASE WHEN _t11.d_day_name = 'Thursday' THEN _s17.ws_ext_sales_price ELSE NULL END + ) AS sum_expr_53, + SUM(CASE WHEN _t11.d_day_name = 'Tuesday' THEN _s17.ws_ext_sales_price ELSE NULL END) AS sum_expr_54, + SUM( + CASE WHEN _t11.d_day_name = 'Wednesday' THEN _s17.ws_ext_sales_price ELSE NULL END + ) AS sum_expr_55 + FROM _t3 AS _t11 + JOIN _s5 AS _s17 + ON _s17.ws_sold_date_sk = _t11.d_date_sk + GROUP BY + 1 +), _u_2 AS ( + SELECT + d_week_seq AS _u_3 + FROM tpcds.date_dim + WHERE + d_year = 2002 + GROUP BY + 1 +) +SELECT + _s2.d_week_seq AS d_week_seq1, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_33, 0) + COALESCE(_s7.sum_expr_40, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_45, 0) + COALESCE(_s19.sum_expr_52, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_45, 0) + COALESCE(_s19.sum_expr_52, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS sunday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_31, 0) + COALESCE(_s7.sum_expr_38, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_43, 0) + COALESCE(_s19.sum_expr_50, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_43, 0) + COALESCE(_s19.sum_expr_50, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS monday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_29, 0) + COALESCE(_s7.sum_expr_36, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_47, 0) + COALESCE(_s19.sum_expr_54, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_47, 0) + COALESCE(_s19.sum_expr_54, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS tuesday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_30, 0) + COALESCE(_s7.sum_expr_37, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_48, 0) + COALESCE(_s19.sum_expr_55, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_48, 0) + COALESCE(_s19.sum_expr_55, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS wednesday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_34, 0) + COALESCE(_s7.sum_expr_41, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_46, 0) + COALESCE(_s19.sum_expr_53, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_46, 0) + COALESCE(_s19.sum_expr_53, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS thursday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr, 0) + COALESCE(_s7.sum_expr, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr, 0) + COALESCE(_s19.sum_expr, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr, 0) + COALESCE(_s19.sum_expr, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS friday_ratio, + ROUND( + CAST(CAST(( + COALESCE(_s3.sum_expr_32, 0) + COALESCE(_s7.sum_expr_39, 0) + ) AS DOUBLE PRECISION) / CASE + WHEN ( + COALESCE(_s15.sum_expr_44, 0) + COALESCE(_s19.sum_expr_51, 0) + ) <> 0 + THEN COALESCE(_s15.sum_expr_44, 0) + COALESCE(_s19.sum_expr_51, 0) + ELSE NULL + END AS DECIMAL), + 2 + ) AS saturday_ratio +FROM _s2 AS _s2 +LEFT JOIN _s3 AS _s3 + ON _s2.d_week_seq = _s3.d_week_seq +LEFT JOIN _s7 AS _s7 + ON _s2.d_week_seq = _s7.d_week_seq +LEFT JOIN _u_0 AS _u_0 + ON _s2.d_week_seq = _u_0._u_1 +JOIN _s11 AS _s11 + ON _s11.d_week_seq = ( + _s2.d_week_seq + 53 + ) +LEFT JOIN _s15 AS _s15 + ON _s11.d_week_seq = _s15.d_week_seq +LEFT JOIN _s19 AS _s19 + ON _s11.d_week_seq = _s19.d_week_seq +LEFT JOIN _u_2 AS _u_2 + ON _s11.d_week_seq = _u_2._u_3 +WHERE + NOT _u_0._u_1 IS NULL AND NOT _u_2._u_3 IS NULL +ORDER BY + 1 NULLS FIRST +LIMIT 10",15.84815134199971,23.590702539000176,"Limit (cost=2050372.51..2050384.46 rows=1 width=232) (actual time=15675.913..15677.526 rows=10 loops=1) + CTE wswscs + -> Finalize GroupAggregate (cost=2040276.49..2043772.35 rows=10409 width=232) (actual time=15101.176..15104.995 rows=263 loops=1) + Group Key: date_dim_2.d_week_seq + -> Gather Merge (cost=2040276.49..2042705.43 rows=20818 width=232) (actual time=15101.144..15102.966 rows=789 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=2039276.47..2039302.49 rows=10409 width=232) (actual time=15087.128..15087.151 rows=263 loops=3) + Sort Key: date_dim_2.d_week_seq + Sort Method: quicksort Memory: 154kB + Worker 0: Sort Method: quicksort Memory: 152kB + Worker 1: Sort Method: quicksort Memory: 154kB + -> Partial HashAggregate (cost=1932828.74..2038581.90 rows=10409 width=232) (actual time=15086.547..15087.031 rows=263 loops=3) + Group Key: date_dim_2.d_week_seq + Planned Partitions: 4 Batches: 1 Memory Usage: 977kB + Worker 0: Batches: 1 Memory Usage: 977kB + Worker 1: Batches: 1 Memory Usage: 977kB + -> Parallel Hash Join (cost=2998.82..993470.13 rows=8999843 width=22) (actual time=251.929..12223.715 rows=7175008 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim_2.d_date_sk) + -> Parallel Append (cost=0.00..903781.64 rows=8999843 width=14) (actual time=0.294..10581.216 rows=7199609 loops=3) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=14) (actual time=0.253..6390.264 rows=4800420 loops=3) + -> Parallel Seq Scan on web_sales (cost=0.00..287023.10 rows=2999110 width=14) (actual time=0.295..5493.941 rows=3598783 loops=2) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=251.014..251.015 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5344kB + -> Parallel Seq Scan on date_dim date_dim_2 (cost=0.00..2461.70 rows=42970 width=24) (actual time=161.337..165.745 rows=24350 loops=3) + -> Merge Join (cost=6600.15..6612.10 rows=1 width=232) (actual time=15115.506..15115.540 rows=10 loops=1) + Merge Cond: (y.d_week_seq1 = ((z.d_week_seq2 - 53))) + -> Subquery Scan on y (cost=3294.14..3306.00 rows=2 width=232) (actual time=15108.844..15108.859 rows=10 loops=1) + Filter: (y.rn1 = 1) + -> WindowAgg (cost=3294.14..3301.44 rows=365 width=240) (actual time=15108.836..15108.850 rows=10 loops=1) + Run Condition: (row_number() OVER (?) <= 1) + -> Sort (cost=3294.14..3295.05 rows=365 width=232) (actual time=15108.808..15108.812 rows=58 loops=1) + Sort Key: wswscs.d_week_seq, wswscs.sun_sales DESC + Sort Method: quicksort Memory: 59kB + -> Hash Join (cost=2949.68..3278.61 rows=365 width=232) (actual time=15107.289..15108.638 rows=365 loops=1) + Hash Cond: (wswscs.d_week_seq = date_dim.d_week_seq) + -> CTE Scan on wswscs (cost=0.00..208.18 rows=10409 width=232) (actual time=15101.179..15103.536 rows=263 loops=1) + -> Hash (cost=2945.11..2945.11 rows=365 width=8) (actual time=4.975..4.975 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=365 width=8) (actual time=2.532..4.939 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + -> Sort (cost=3306.01..3306.02 rows=2 width=232) (actual time=6.646..6.648 rows=10 loops=1) + Sort Key: ((z.d_week_seq2 - 53)) + Sort Method: quicksort Memory: 30kB + -> Subquery Scan on z (cost=3294.14..3306.00 rows=2 width=232) (actual time=6.563..6.626 rows=53 loops=1) + Filter: (z.rn2 = 1) + -> WindowAgg (cost=3294.14..3301.44 rows=365 width=240) (actual time=6.559..6.617 rows=53 loops=1) + Run Condition: (row_number() OVER (?) <= 1) + -> Sort (cost=3294.14..3295.05 rows=365 width=232) (actual time=6.549..6.564 rows=365 loops=1) + Sort Key: wswscs_1.d_week_seq, wswscs_1.sun_sales DESC + Sort Method: quicksort Memory: 59kB + -> Hash Join (cost=2949.68..3278.61 rows=365 width=232) (actual time=6.402..6.438 rows=365 loops=1) + Hash Cond: (wswscs_1.d_week_seq = date_dim_1.d_week_seq) + -> CTE Scan on wswscs wswscs_1 (cost=0.00..208.18 rows=10409 width=232) (actual time=0.000..0.017 rows=263 loops=1) + -> Hash (cost=2945.11..2945.11 rows=365 width=8) (actual time=6.352..6.352 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> Seq Scan on date_dim date_dim_1 (cost=0.00..2945.11 rows=365 width=8) (actual time=3.297..6.293 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 +Planning Time: 0.409 ms +JIT: + Functions: 94 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.173 ms, Inlining 124.338 ms, Optimization 534.934 ms, Emission 385.390 ms, Total 1050.836 ms +Execution Time: 15680.794 ms","Limit (cost=24716894.46..24716942.38 rows=10 width=232) (actual time=24314.873..24315.276 rows=10 loops=1) + CTE _t1 + -> Seq Scan on date_dim date_dim_2 (cost=0.00..3127.73 rows=1454 width=16) (actual time=2.799..5.404 rows=1461 loops=1) + Filter: ((d_year <= 2003) AND (d_year >= 2000)) + Rows Removed by Filter: 71588 + CTE _t3 + -> Seq Scan on date_dim date_dim_3 (cost=0.00..3127.73 rows=1454 width=32) (actual time=2.530..5.124 rows=1461 loops=1) + Filter: ((d_year <= 2003) AND (d_year >= 2000)) + Rows Removed by Filter: 71588 + CTE _s1 + -> Seq Scan on catalog_sales (cost=0.00..655769.59 rows=14401759 width=14) (actual time=0.317..3946.147 rows=14401261 loops=1) + CTE _s5 + -> Seq Scan on web_sales (cost=0.00..329010.64 rows=7197864 width=14) (actual time=0.365..1537.140 rows=7197566 loops=1) + -> Merge Join (cost=23725858.76..23728963.95 rows=648 width=232) (actual time=23260.632..23261.020 rows=10 loops=1) + Merge Cond: (_t1.d_week_seq = date_dim_1.d_week_seq) + -> Nested Loop (cost=23722881.01..23725874.95 rows=360 width=904) (actual time=23256.366..23256.688 rows=10 loops=1) + Join Filter: (_t1_1.d_week_seq = date_dim.d_week_seq) + Rows Removed by Join Filter: 2801 + -> Nested Loop Left Join (cost=23719920.36..23721836.95 rows=200 width=912) (actual time=23249.382..23251.374 rows=62 loops=1) + Join Filter: (_t1_1.d_week_seq = _s19.d_week_seq) + Rows Removed by Join Filter: 5138 + -> Nested Loop Left Join (cost=19767705.94..19769017.51 rows=200 width=688) (actual time=20781.677..20783.002 rows=62 loops=1) + Join Filter: (_t1_1.d_week_seq = _s15.d_week_seq) + Rows Removed by Join Filter: 5169 + -> Nested Loop (cost=11860012.86..11860719.40 rows=200 width=464) (actual time=16051.637..16052.267 rows=62 loops=1) + Join Filter: ((_t1.d_week_seq + 53) = _t1_1.d_week_seq) + Rows Removed by Join Filter: 7116 + -> Merge Left Join (cost=11859980.15..11859987.65 rows=200 width=456) (actual time=16051.380..16051.445 rows=62 loops=1) + Merge Cond: (_t1.d_week_seq = _s7.d_week_seq) + -> Merge Left Join (cost=7907750.58..7907754.58 rows=200 width=232) (actual time=10916.850..10916.885 rows=62 loops=1) + Merge Cond: (_t1.d_week_seq = _s3.d_week_seq) + -> Sort (cost=42.36..42.86 rows=200 width=8) (actual time=5.921..5.925 rows=62 loops=1) + Sort Key: _t1.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> HashAggregate (cost=32.72..34.72 rows=200 width=8) (actual time=5.834..5.855 rows=210 loops=1) + Group Key: _t1.d_week_seq + Batches: 1 Memory Usage: 48kB + -> CTE Scan on _t1 (cost=0.00..29.08 rows=1454 width=8) (actual time=2.804..5.653 rows=1461 loops=1) + -> Sort (cost=7907708.23..7907708.73 rows=200 width=232) (actual time=10910.918..10910.929 rows=62 loops=1) + Sort Key: _s3.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 39kB + -> Subquery Scan on _s3 (cost=7907693.08..7907700.58 rows=200 width=232) (actual time=10910.706..10910.879 rows=159 loops=1) + -> HashAggregate (cost=7907693.08..7907698.58 rows=200 width=232) (actual time=10910.703..10910.864 rows=159 loops=1) + Group Key: _t3.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=47.26..3981413.53 rows=104700788 width=60) (actual time=6.015..8582.685 rows=8627065 loops=1) + Hash Cond: (_s1.cs_sold_date_sk = _t3.d_date_sk) + -> CTE Scan on _s1 (cost=0.00..288035.18 rows=14401759 width=22) (actual time=0.318..6907.836 rows=14401261 loops=1) + -> Hash (cost=29.08..29.08 rows=1454 width=54) (actual time=5.619..5.620 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 (cost=0.00..29.08 rows=1454 width=54) (actual time=2.533..5.458 rows=1461 loops=1) + -> Sort (cost=3952229.56..3952230.06 rows=200 width=232) (actual time=5134.520..5134.530 rows=62 loops=1) + Sort Key: _s7.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 39kB + -> Subquery Scan on _s7 (cost=3952214.42..3952221.92 rows=200 width=232) (actual time=5134.349..5134.477 rows=158 loops=1) + -> HashAggregate (cost=3952214.42..3952219.92 rows=200 width=232) (actual time=5134.346..5134.462 rows=158 loops=1) + Group Key: _t5.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=47.26..1989896.75 rows=52328471 width=60) (actual time=0.664..3909.714 rows=4334472 loops=1) + Hash Cond: (_s5.ws_sold_date_sk = _t5.d_date_sk) + -> CTE Scan on _s5 (cost=0.00..143957.28 rows=7197864 width=22) (actual time=0.366..3016.425 rows=7197566 loops=1) + -> Hash (cost=29.08..29.08 rows=1454 width=54) (actual time=0.276..0.276 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t5 (cost=0.00..29.08 rows=1454 width=54) (actual time=0.003..0.106 rows=1461 loops=1) + -> Materialize (cost=32.72..35.72 rows=200 width=8) (actual time=0.004..0.009 rows=116 loops=62) + -> HashAggregate (cost=32.72..34.72 rows=200 width=8) (actual time=0.245..0.266 rows=209 loops=1) + Group Key: _t1_1.d_week_seq + Batches: 1 Memory Usage: 48kB + -> CTE Scan on _t1 _t1_1 (cost=0.00..29.08 rows=1454 width=8) (actual time=0.001..0.084 rows=1461 loops=1) + -> Materialize (cost=7907693.08..7907701.58 rows=200 width=232) (actual time=76.291..76.297 rows=84 loops=62) + -> Subquery Scan on _s15 (cost=7907693.08..7907700.58 rows=200 width=232) (actual time=4730.027..4730.187 rows=157 loops=1) + -> HashAggregate (cost=7907693.08..7907698.58 rows=200 width=232) (actual time=4730.024..4730.172 rows=157 loops=1) + Group Key: _t9.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=47.26..3981413.53 rows=104700788 width=60) (actual time=0.432..2559.643 rows=8627065 loops=1) + Hash Cond: (_s13.cs_sold_date_sk = _t9.d_date_sk) + -> CTE Scan on _s1 _s13 (cost=0.00..288035.18 rows=14401759 width=22) (actual time=0.119..1015.331 rows=14401261 loops=1) + -> Hash (cost=29.08..29.08 rows=1454 width=54) (actual time=0.287..0.288 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t9 (cost=0.00..29.08 rows=1454 width=54) (actual time=0.004..0.106 rows=1461 loops=1) + -> Materialize (cost=3952214.42..3952222.92 rows=200 width=232) (actual time=39.802..39.807 rows=84 loops=62) + -> Subquery Scan on _s19 (cost=3952214.42..3952221.92 rows=200 width=232) (actual time=2467.691..2467.818 rows=156 loops=1) + -> HashAggregate (cost=3952214.42..3952219.92 rows=200 width=232) (actual time=2467.688..2467.803 rows=156 loops=1) + Group Key: _t11.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=47.26..1989896.75 rows=52328471 width=60) (actual time=0.326..1323.875 rows=4334472 loops=1) + Hash Cond: (_s17.ws_sold_date_sk = _t11.d_date_sk) + -> CTE Scan on _s5 _s17 (cost=0.00..143957.28 rows=7197864 width=22) (actual time=0.037..507.603 rows=7197566 loops=1) + -> Hash (cost=29.08..29.08 rows=1454 width=54) (actual time=0.270..0.270 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t11 (cost=0.00..29.08 rows=1454 width=54) (actual time=0.004..0.107 rows=1461 loops=1) + -> Materialize (cost=2960.65..2964.27 rows=360 width=8) (actual time=0.081..0.084 rows=45 loops=62) + -> Group (cost=2960.65..2962.47 rows=360 width=8) (actual time=5.037..5.073 rows=53 loops=1) + Group Key: date_dim.d_week_seq + -> Sort (cost=2960.65..2961.56 rows=365 width=8) (actual time=5.033..5.047 rows=365 loops=1) + Sort Key: date_dim.d_week_seq + Sort Method: quicksort Memory: 25kB + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=365 width=8) (actual time=2.561..5.006 rows=365 loops=1) + Filter: ((d_week_seq IS NOT NULL) AND (d_year = 2002)) + Rows Removed by Filter: 72684 + -> Sort (cost=2977.76..2978.66 rows=360 width=8) (actual time=4.233..4.234 rows=10 loops=1) + Sort Key: date_dim_1.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> Group (cost=2960.65..2962.47 rows=360 width=8) (actual time=4.190..4.225 rows=53 loops=1) + Group Key: date_dim_1.d_week_seq + -> Sort (cost=2960.65..2961.56 rows=365 width=8) (actual time=4.186..4.201 rows=365 loops=1) + Sort Key: date_dim_1.d_week_seq + Sort Method: quicksort Memory: 25kB + -> Seq Scan on date_dim date_dim_1 (cost=0.00..2945.11 rows=365 width=8) (actual time=2.223..4.168 rows=365 loops=1) + Filter: ((d_week_seq IS NOT NULL) AND (d_year = 2001)) + Rows Removed by Filter: 72684 +Planning Time: 2.255 ms +JIT: + Functions: 132 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.525 ms, Inlining 12.218 ms, Optimization 592.175 ms, Emission 450.122 ms, Total 1060.040 ms +Execution Time: 24394.093 ms",SUCCESS +24,25,TPCDS,Q3,"SELECT + dt.d_year, + item.i_brand_id AS brand_id, + item.i_brand AS brand, + SUM(ss_ext_sales_price) AS sum_agg +FROM tpcds.date_dim dt +JOIN tpcds.store_sales ON dt.d_date_sk = store_sales.ss_sold_date_sk +JOIN tpcds.item ON store_sales.ss_item_sk = item.i_item_sk +WHERE item.i_manufact_id = 128 + AND dt.d_moy = 11 +GROUP BY + dt.d_year, + item.i_brand, + item.i_brand_id +ORDER BY + dt.d_year, + sum_agg DESC, + brand_id +LIMIT 100;","result = items.WHERE( + (manufacturer_id == 128) +).CALCULATE(brand_id, brand).store_sales.WHERE(sold_date.month_of_year == 11).CALCULATE( + sold_year=sold_date.year, + brand_id=brand_id, + brand=brand, + extended_price=ext_sales_price +).PARTITION( + name=""year"", by=(sold_year, brand_id, brand) +).CALCULATE( + d_year=sold_year, + brand_id=brand_id, + brand=brand, + sum_agg=SUM(store_sales.extended_price) +).TOP_K(100, by=(sold_year, sum_agg.DESC(), brand_id))","SELECT + date_dim.d_year, + item.i_brand_id AS brand_id, + item.i_brand AS brand, + COALESCE(SUM(store_sales.ss_ext_sales_price), 0) AS sum_agg +FROM tpcds.item AS item +JOIN tpcds.store_sales AS store_sales + ON item.i_item_sk = store_sales.ss_item_sk +JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk AND date_dim.d_moy = 11 +WHERE + item.i_manufact_id = 128 +GROUP BY + 1, + 2, + 3 +ORDER BY + 1 NULLS FIRST, + 4 DESC NULLS LAST, + 2 NULLS FIRST +LIMIT 100",18.798808724000082,19.803773456999807,"Limit (cost=75028.37..205695.42 rows=100 width=65) (actual time=26406.662..26539.170 rows=100 loops=1) + -> Incremental Sort (cost=75028.37..6548274.14 rows=4954 width=65) (actual time=26393.224..26525.725 rows=100 loops=1) + Sort Key: dt.d_year, (sum(store_sales.ss_ext_sales_price)) DESC, item.i_brand_id + Presorted Key: dt.d_year + Full-sort Groups: 2 Sort Methods: top-N heapsort, quicksort Average Memory: 29kB Peak Memory: 29kB + Pre-sorted Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB + -> GroupAggregate (cost=42499.83..6548093.51 rows=4954 width=65) (actual time=26260.061..26525.571 rows=141 loops=1) + Group Key: dt.d_year, item.i_brand, item.i_brand_id + -> Incremental Sort (cost=42499.83..6547982.05 rows=4954 width=39) (actual time=26260.032..26525.025 rows=3387 loops=1) + Sort Key: dt.d_year, item.i_brand, item.i_brand_id + Presorted Key: dt.d_year + Full-sort Groups: 3 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB + Pre-sorted Groups: 3 Sort Method: quicksort Average Memory: 160kB Peak Memory: 161kB + -> Nested Loop (cost=9809.29..6547801.43 rows=4954 width=39) (actual time=26127.484..26521.959 rows=4885 loops=1) + Join Filter: (dt.d_date_sk = store_sales.ss_sold_date_sk) + Rows Removed by Join Filter: 156946184 + -> Gather Merge (cost=3772.85..4444.14 rows=5890 width=16) (actual time=17.229..18.011 rows=3031 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2772.84..2781.51 rows=3465 width=16) (actual time=3.703..3.872 rows=1516 loops=2) + Sort Key: dt.d_year + Sort Method: quicksort Memory: 427kB + Worker 0: Sort Method: quicksort Memory: 25kB + -> Parallel Seq Scan on date_dim dt (cost=0.00..2569.12 rows=3465 width=16) (actual time=0.031..3.400 rows=3000 loops=2) + Filter: (d_moy = 11) + Rows Removed by Filter: 33524 + -> Materialize (cost=6036.44..855456.89 rows=64381 width=39) (actual time=0.017..6.265 rows=51782 loops=3031) + -> Gather (cost=6036.44..855134.98 rows=64381 width=39) (actual time=51.178..13233.024 rows=51799 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5036.44..847696.88 rows=26825 width=39) (actual time=37.432..13223.815 rows=17266 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=22) (actual time=0.179..12159.120 rows=9600330 loops=3) + -> Parallel Hash (cost=5035.25..5035.25 rows=95 width=33) (actual time=36.275..36.275 rows=60 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=95 width=33) (actual time=8.672..36.201 rows=60 loops=3) + Filter: (i_manufact_id = 128) + Rows Removed by Filter: 33940 +Planning Time: 0.187 ms +JIT: + Functions: 57 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.971 ms, Inlining 0.000 ms, Optimization 1.825 ms, Emission 32.675 ms, Total 38.471 ms +Execution Time: 26540.968 ms","Limit (cost=75028.37..205695.42 rows=100 width=65) (actual time=27270.967..27411.912 rows=100 loops=1) + -> Incremental Sort (cost=75028.37..6548274.14 rows=4954 width=65) (actual time=27257.527..27398.464 rows=100 loops=1) + Sort Key: date_dim.d_year NULLS FIRST, (COALESCE(sum(store_sales.ss_ext_sales_price), '0'::numeric)) DESC NULLS LAST, item.i_brand_id NULLS FIRST + Presorted Key: date_dim.d_year + Full-sort Groups: 2 Sort Methods: top-N heapsort, quicksort Average Memory: 29kB Peak Memory: 29kB + Pre-sorted Groups: 2 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB + -> GroupAggregate (cost=42499.83..6548093.51 rows=4954 width=65) (actual time=27116.390..27398.286 rows=141 loops=1) + Group Key: date_dim.d_year, item.i_brand_id, item.i_brand + -> Incremental Sort (cost=42499.83..6547982.05 rows=4954 width=39) (actual time=27116.351..27397.724 rows=3380 loops=1) + Sort Key: date_dim.d_year NULLS FIRST, item.i_brand_id NULLS FIRST, item.i_brand + Presorted Key: date_dim.d_year + Full-sort Groups: 3 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB + Pre-sorted Groups: 3 Sort Method: quicksort Average Memory: 160kB Peak Memory: 161kB + -> Nested Loop (cost=9809.29..6547801.43 rows=4954 width=39) (actual time=26975.985..27396.399 rows=4885 loops=1) + Join Filter: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + Rows Removed by Join Filter: 156946221 + -> Gather Merge (cost=3772.85..4444.14 rows=5890 width=16) (actual time=19.404..20.185 rows=3031 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2772.84..2781.51 rows=3465 width=16) (actual time=5.479..5.648 rows=1516 loops=2) + Sort Key: date_dim.d_year NULLS FIRST + Sort Method: quicksort Memory: 427kB + Worker 0: Sort Method: quicksort Memory: 25kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=3465 width=16) (actual time=0.023..5.021 rows=3000 loops=2) + Filter: (d_moy = 11) + Rows Removed by Filter: 33524 + -> Materialize (cost=6036.44..855456.89 rows=64381 width=39) (actual time=0.021..6.264 rows=51782 loops=3031) + -> Gather (cost=6036.44..855134.98 rows=64381 width=39) (actual time=63.752..13227.175 rows=51799 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5036.44..847696.88 rows=26825 width=39) (actual time=50.245..13219.162 rows=17266 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=22) (actual time=0.182..12165.239 rows=9600330 loops=3) + -> Parallel Hash (cost=5035.25..5035.25 rows=95 width=33) (actual time=49.058..49.059 rows=60 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=95 width=33) (actual time=7.856..48.987 rows=60 loops=3) + Filter: (i_manufact_id = 128) + Rows Removed by Filter: 33940 +Planning Time: 0.219 ms +JIT: + Functions: 57 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.985 ms, Inlining 0.000 ms, Optimization 1.759 ms, Emission 32.606 ms, Total 38.349 ms +Execution Time: 27413.858 ms",SUCCESS +25,26,TPCDS,Q6,"WITH month_seq AS ( + SELECT d_month_seq + FROM tpcds.date_dim + WHERE d_year = 2001 + AND d_moy = 1 + LIMIT 1 +), +category_avg AS ( + SELECT i_category, + AVG(i_current_price) AS avg_price + FROM tpcds.item + GROUP BY i_category +) +SELECT + a.ca_state AS state, + COUNT(*) AS cnt +FROM tpcds.customer_address a +JOIN tpcds.customer c ON a.ca_address_sk = c.c_current_addr_sk +JOIN tpcds.store_sales s ON c.c_customer_sk = s.ss_customer_sk +JOIN tpcds.date_dim d ON s.ss_sold_date_sk = d.d_date_sk +JOIN tpcds.item i ON s.ss_item_sk = i.i_item_sk +JOIN category_avg ca ON i.i_category = ca.i_category +WHERE d.d_month_seq = (SELECT d_month_seq FROM month_seq) + AND i.i_current_price > 1.2 * ca.avg_price +GROUP BY a.ca_state +HAVING COUNT(*) >= 10 +ORDER BY cnt, a.ca_state +LIMIT 10;","selected_month_sold = sold_date.WHERE((month_of_year == 1) & (year == 2001)) +result = items.PARTITION( + name=""item_category"", + by=category +).CALCULATE( + category_avg=AVG(items.current_price) +).items.store_sales.WHERE( + (HAS(selected_month_sold)) + & (item.current_price > 1.2*category_avg) +).customer.CALCULATE( + state=current_address.state +).PARTITION( + name=""state"", by=state +).CALCULATE( + state, + cnt=COUNT(customer) +).WHERE(cnt >= 10).TOP_K(10, by=(cnt, state))","WITH _s0 AS ( + SELECT + i_category, + AVG(CAST(i_current_price AS DECIMAL)) AS avg_i_current_price + FROM tpcds.item + GROUP BY + 1 +), _t1 AS ( + SELECT + customer_address.ca_state, + COUNT(*) AS n_rows + FROM _s0 AS _s0 + JOIN tpcds.item AS item + ON _s0.i_category = item.i_category + JOIN tpcds.store_sales AS store_sales + ON item.i_item_sk = store_sales.ss_item_sk + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk + AND date_dim.d_moy = 1 + AND date_dim.d_year = 2001 + JOIN tpcds.item AS item_2 + ON item_2.i_current_price > ( + 1.2 * _s0.avg_i_current_price + ) + AND item_2.i_item_sk = store_sales.ss_item_sk + JOIN tpcds.customer AS customer + ON customer.c_customer_sk = store_sales.ss_customer_sk + LEFT JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + GROUP BY + 1 +) +SELECT + ca_state AS state, + n_rows AS cnt +FROM _t1 +WHERE + n_rows >= 10 +ORDER BY + 2 NULLS FIRST, + 1 NULLS FIRST +LIMIT 10",14.034591649000049,14.18810382599986,"Limit (cost=878274.45..878274.47 rows=10 width=11) (actual time=14025.743..14032.675 rows=10 loops=1) + InitPlan 1 (returns $0) + -> Limit (cost=0.00..100.89 rows=1 width=8) (actual time=2.715..2.716 rows=1 loops=1) + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=31 width=8) (actual time=2.710..2.710 rows=1 loops=1) + Filter: ((d_year = 2001) AND (d_moy = 1)) + Rows Removed by Filter: 36889 + -> Sort (cost=878173.55..878173.59 rows=17 width=11) (actual time=13637.440..13644.368 rows=10 loops=1) + Sort Key: (count(*)), a.ca_state + Sort Method: top-N heapsort Memory: 25kB + -> Finalize GroupAggregate (cost=878148.56..878173.20 rows=17 width=11) (actual time=13635.889..13644.337 rows=51 loops=1) + Group Key: a.ca_state + Filter: (count(*) >= 10) + Rows Removed by Filter: 1 + -> Gather Merge (cost=878148.56..878172.06 rows=102 width=11) (actual time=13635.833..13644.268 rows=156 loops=1) + Workers Planned: 2 + Params Evaluated: $0 + Workers Launched: 2 + -> Partial GroupAggregate (cost=877148.54..877160.26 rows=51 width=11) (actual time=13615.946..13617.054 rows=52 loops=3) + Group Key: a.ca_state + -> Sort (cost=877148.54..877152.27 rows=1495 width=3) (actual time=13615.910..13616.351 rows=9110 loops=3) + Sort Key: a.ca_state + Sort Method: quicksort Memory: 512kB + Worker 0: Sort Method: quicksort Memory: 546kB + Worker 1: Sort Method: quicksort Memory: 317kB + -> Parallel Hash Join (cost=871143.18..877069.71 rows=1495 width=3) (actual time=13524.352..13612.614 rows=9110 loops=3) + Hash Cond: (a.ca_address_sk = c.c_current_addr_sk) + -> Parallel Seq Scan on customer_address a (cost=0.00..5529.67 rows=104167 width=11) (actual time=0.113..77.055 rows=83333 loops=3) + -> Parallel Hash (cost=871124.49..871124.49 rows=1495 width=8) (actual time=13523.551..13523.559 rows=9110 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1600kB + -> Parallel Hash Join (cost=856381.68..871124.49 rows=1495 width=8) (actual time=13340.850..13514.009 rows=9110 loops=3) + Hash Cond: (c.c_customer_sk = s.ss_customer_sk) + -> Parallel Seq Scan on customer c (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.179..152.971 rows=166667 loops=3) + -> Parallel Hash (cost=856362.13..856362.13 rows=1564 width=8) (actual time=13340.602..13340.608 rows=9322 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1632kB + -> Hash Join (cost=851239.29..856362.13 rows=1564 width=8) (actual time=13231.198..13334.181 rows=9322 loops=3) + Hash Cond: ((i.i_category)::text = (item.i_category)::text) + Join Filter: (i.i_current_price > (1.2 * (avg(item.i_current_price)))) + Rows Removed by Join Filter: 86795 + -> Parallel Hash Join (cost=845205.04..850313.02 rows=4704 width=20) (actual time=12851.160..12917.845 rows=96339 loops=3) + Hash Cond: (i.i_item_sk = s.ss_item_sk) + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=20) (actual time=0.108..42.474 rows=34000 loops=3) + -> Parallel Hash (cost=845146.24..845146.24 rows=4704 width=16) (actual time=12850.961..12850.964 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 21600kB + -> Parallel Hash Join (cost=2569.35..845146.24 rows=4704 width=16) (actual time=17.163..12732.961 rows=96339 loops=3) + Hash Cond: (s.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales s (cost=0.00..797545.22 rows=12000922 width=24) (actual time=13.768..11897.625 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=18 width=8) (actual time=2.336..2.337 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=18 width=8) (actual time=3.552..6.993 rows=31 loops=1) + Filter: (d_month_seq = $0) + Rows Removed by Filter: 73018 + -> Hash (cost=6034.12..6034.12 rows=10 width=38) (actual time=379.827..379.828 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> HashAggregate (cost=6034.00..6034.12 rows=10 width=38) (actual time=379.813..379.819 rows=11 loops=3) + Group Key: item.i_category + Batches: 1 Memory Usage: 24kB + Worker 0: Batches: 1 Memory Usage: 24kB + Worker 1: Batches: 1 Memory Usage: 24kB + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=12) (actual time=0.013..16.168 rows=102000 loops=3) +Planning Time: 0.557 ms +JIT: + Functions: 182 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.865 ms, Inlining 193.399 ms, Optimization 738.274 ms, Emission 451.589 ms, Total 1390.127 ms +Execution Time: 14228.588 ms","Limit (cost=883458.56..883458.58 rows=10 width=11) (actual time=13932.368..13942.507 rows=10 loops=1) + -> Sort (cost=883458.56..883458.60 rows=17 width=11) (actual time=13549.579..13559.716 rows=10 loops=1) + Sort Key: (count(*)) NULLS FIRST, customer_address.ca_state NULLS FIRST + Sort Method: top-N heapsort Memory: 25kB + -> Finalize GroupAggregate (cost=883433.19..883458.21 rows=17 width=11) (actual time=13548.389..13559.693 rows=51 loops=1) + Group Key: customer_address.ca_state + Filter: (count(*) >= 10) + Rows Removed by Filter: 1 + -> Gather Merge (cost=883433.19..883457.06 rows=102 width=11) (actual time=13548.346..13559.656 rows=155 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=882433.17..882445.27 rows=51 width=11) (actual time=13531.207..13532.408 rows=52 loops=3) + Group Key: customer_address.ca_state + -> Sort (cost=882433.17..882437.03 rows=1545 width=3) (actual time=13531.180..13531.668 rows=9110 loops=3) + Sort Key: customer_address.ca_state + Sort Method: quicksort Memory: 554kB + Worker 0: Sort Method: quicksort Memory: 311kB + Worker 1: Sort Method: quicksort Memory: 511kB + -> Parallel Hash Right Join (cost=876424.60..882351.33 rows=1545 width=3) (actual time=13465.556..13528.082 rows=9110 loops=3) + Hash Cond: (customer_address.ca_address_sk = customer.c_current_addr_sk) + -> Parallel Seq Scan on customer_address (cost=0.00..5529.67 rows=104167 width=11) (actual time=0.196..51.536 rows=83333 loops=3) + -> Parallel Hash (cost=876405.29..876405.29 rows=1545 width=8) (actual time=13465.156..13465.163 rows=9110 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1600kB + -> Parallel Hash Join (cost=861662.27..876405.29 rows=1545 width=8) (actual time=13338.371..13455.501 rows=9110 loops=3) + Hash Cond: (customer.c_customer_sk = store_sales.ss_customer_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.286..97.383 rows=166667 loops=3) + -> Parallel Hash (cost=861642.07..861642.07 rows=1616 width=8) (actual time=13337.799..13337.807 rows=9322 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1568kB + -> Hash Join (cost=856518.07..861642.07 rows=1616 width=8) (actual time=13271.687..13331.037 rows=9322 loops=3) + Hash Cond: ((item.i_category)::text = (item_1.i_category)::text) + Join Filter: (item_2.i_current_price > (1.2 * (avg((item_1.i_current_price)::numeric)))) + Rows Removed by Join Filter: 86795 + -> Parallel Hash Join (cost=850483.82..855592.44 rows=4861 width=20) (actual time=12884.219..12906.539 rows=96339 loops=3) + Hash Cond: (item_2.i_item_sk = item.i_item_sk) + -> Parallel Seq Scan on item item_2 (cost=0.00..4929.00 rows=42500 width=14) (actual time=0.007..5.364 rows=34000 loops=3) + -> Parallel Hash (cost=850423.06..850423.06 rows=4861 width=30) (actual time=12884.124..12884.129 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 26592kB + -> Parallel Hash Join (cost=845314.43..850423.06 rows=4861 width=30) (actual time=12818.716..12851.165 rows=96339 loops=3) + Hash Cond: (item.i_item_sk = store_sales.ss_item_sk) + -> Parallel Seq Scan on item (cost=0.00..4929.00 rows=42500 width=14) (actual time=0.011..5.566 rows=34000 loops=3) + -> Parallel Hash (cost=845253.67..845253.67 rows=4861 width=16) (actual time=12818.620..12818.622 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 21632kB + -> Parallel Hash Join (cost=2676.78..845253.67 rows=4861 width=16) (actual time=3.113..12702.815 rows=96339 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=24) (actual time=0.180..11861.803 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=2.464..2.465 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=18 width=8) (actual time=3.762..7.379 rows=31 loops=1) + Filter: ((d_moy = 1) AND (d_year = 2001)) + Rows Removed by Filter: 73018 + -> Hash (cost=6034.12..6034.12 rows=10 width=38) (actual time=387.433..387.434 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> HashAggregate (cost=6034.00..6034.12 rows=10 width=38) (actual time=387.416..387.423 rows=11 loops=3) + Group Key: item_1.i_category + Batches: 1 Memory Usage: 24kB + Worker 0: Batches: 1 Memory Usage: 24kB + Worker 1: Batches: 1 Memory Usage: 24kB + -> Seq Scan on item item_1 (cost=0.00..5524.00 rows=102000 width=12) (actual time=0.014..15.259 rows=102000 loops=3) +Planning Time: 1.036 ms +JIT: + Functions: 194 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.754 ms, Inlining 155.250 ms, Optimization 787.821 ms, Emission 459.813 ms, Total 1410.639 ms +Execution Time: 13944.510 ms",SUCCESS +26,27,TPCDS,Q7,"SELECT + i.i_item_id, + AVG(ss.ss_quantity) AS agg1, + AVG(ss.ss_list_price) AS agg2, + AVG(ss.ss_coupon_amt) AS agg3, + AVG(ss.ss_sales_price) AS agg4 +FROM tpcds.store_sales ss +JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk +JOIN tpcds.item i + ON ss.ss_item_sk = i.i_item_sk +JOIN tpcds.customer_demographics cd + ON ss.ss_cdemo_sk = cd.cd_demo_sk +JOIN tpcds.promotion p + ON ss.ss_promo_sk = p.p_promo_sk +WHERE + cd.cd_gender = 'M' + AND cd.cd_marital_status = 'S' + AND cd.cd_education_status = 'College' + AND (p.p_channel_email = 'N' OR p.p_channel_event = 'N') + AND d.d_year = 2000 +GROUP BY + i.i_item_id +ORDER BY + i.i_item_id +LIMIT 10;","filtered_sales = store_sales.WHERE( + (customer_demographics.gender == 'M') + & (customer_demographics.marital_status == 'S') + & (customer_demographics.education_status == 'College') + & (promotion.channel_email == 'N') + & (promotion.channel_event == 'N') + & (sold_date.year == 2000) +) + +result = items.WHERE(HAS(filtered_sales)).CALCULATE( + i_item_id=_id, + agg1=AVG(filtered_sales.quantity), + agg2=AVG(filtered_sales.list_price), + agg3=AVG(filtered_sales.coupon_amount), + agg4=AVG(filtered_sales.sales_price) +).TOP_K(10, by=_id)","WITH _s7 AS ( + SELECT + store_sales.ss_item_sk, + AVG(CAST(store_sales.ss_coupon_amt AS DECIMAL)) AS avg_ss_coupon_amt, + AVG(CAST(store_sales.ss_list_price AS DECIMAL)) AS avg_ss_list_price, + AVG(CAST(store_sales.ss_quantity AS DECIMAL)) AS avg_ss_quantity, + AVG(CAST(store_sales.ss_sales_price AS DECIMAL)) AS avg_ss_sales_price + FROM tpcds.store_sales AS store_sales + JOIN tpcds.customer_demographics AS customer_demographics + ON customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk + AND customer_demographics.cd_education_status = 'College' + AND customer_demographics.cd_gender = 'M' + AND customer_demographics.cd_marital_status = 'S' + JOIN tpcds.promotion AS promotion + ON promotion.p_channel_email = 'N' + AND promotion.p_channel_event = 'N' + AND promotion.p_promo_sk = store_sales.ss_promo_sk + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk AND date_dim.d_year = 2000 + GROUP BY + 1 +) +SELECT + item.i_item_id, + _s7.avg_ss_quantity AS agg1, + _s7.avg_ss_list_price AS agg2, + _s7.avg_ss_coupon_amt AS agg3, + _s7.avg_ss_sales_price AS agg4 +FROM tpcds.item AS item +JOIN _s7 AS _s7 + ON _s7.ss_item_sk = item.i_item_sk +ORDER BY + 1 NULLS FIRST +LIMIT 10",14.053880951000338,14.425270048999664,"Limit (cost=50013.17..70088.35 rows=10 width=145) (actual time=13839.482..14098.428 rows=10 loops=1) + -> GroupAggregate (cost=50013.17..3645478.58 rows=1791 width=145) (actual time=13839.481..14098.426 rows=10 loops=1) + Group Key: i.i_item_id + -> Nested Loop (cost=50013.17..3645420.37 rows=1791 width=40) (actual time=13815.057..14098.375 rows=19 loops=1) + Join Filter: (ss.ss_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 2416370 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=168.065..172.093 rows=33 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=104.775..104.818 rows=786 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 1229kB + Worker 1: Sort Method: quicksort Memory: 3095kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=0.006..8.391 rows=34000 loops=3) + -> Materialize (cost=40816.92..884119.02 rows=1791 width=31) (actual time=11.053..417.407 rows=73224 loops=33) + -> Gather (cost=40816.92..884110.06 rows=1791 width=31) (actual time=364.695..13598.566 rows=75483 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=39816.92..882930.96 rows=746 width=31) (actual time=352.746..13599.242 rows=25161 loops=3) + Hash Cond: (ss.ss_promo_sk = p.p_promo_sk) + -> Parallel Hash Join (cost=39792.17..882895.82 rows=780 width=39) (actual time=352.400..13591.119 rows=25586 loops=3) + Hash Cond: (ss.ss_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..845457.60 rows=57230 width=47) (actual time=4.619..13055.944 rows=1839779 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=55) (actual time=0.670..11698.393 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=3.897..3.898 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=215 width=8) (actual time=1.969..3.833 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=345.186..345.186 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11402 width=8) (actual time=0.180..342.015 rows=9147 loops=3) + Filter: (((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text) AND ((cd_education_status)::text = 'College'::text)) + Rows Removed by Filter: 631120 + -> Hash (cost=18.50..18.50 rows=500 width=8) (actual time=0.193..0.194 rows=498 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 28kB + -> Seq Scan on promotion p (cost=0.00..18.50 rows=500 width=8) (actual time=0.020..0.132 rows=498 loops=3) + Filter: (((p_channel_email)::text = 'N'::text) OR ((p_channel_event)::text = 'N'::text)) + Rows Removed by Filter: 2 +Planning Time: 0.332 ms +Execution Time: 14099.297 ms","Limit (cost=890096.62..890096.64 rows=10 width=145) (actual time=14100.354..14100.999 rows=10 loops=1) + -> Sort (cost=890096.62..890100.98 rows=1745 width=145) (actual time=13789.586..13790.230 rows=10 loops=1) + Sort Key: item.i_item_id NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> Hash Join (cost=884267.15..890058.91 rows=1745 width=145) (actual time=13750.337..13779.274 rows=39288 loops=1) + Hash Cond: (item.i_item_sk = _s7.ss_item_sk) + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=25) (actual time=0.036..12.084 rows=102000 loops=1) + -> Hash (cost=884245.33..884245.33 rows=1745 width=136) (actual time=13750.267..13750.910 rows=39288 loops=1) + Buckets: 65536 (originally 2048) Batches: 1 (originally 1) Memory Usage: 3153kB + -> Subquery Scan on _s7 (cost=883965.18..884245.33 rows=1745 width=136) (actual time=13610.528..13743.821 rows=39288 loops=1) + -> Finalize GroupAggregate (cost=883965.18..884227.88 rows=1745 width=136) (actual time=13610.524..13740.764 rows=39288 loops=1) + Group Key: store_sales.ss_item_sk + -> Gather Merge (cost=883965.18..884160.27 rows=1454 width=136) (actual time=13610.497..13649.077 rows=58292 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=882965.15..882992.42 rows=727 width=136) (actual time=13595.320..13625.645 rows=19431 loops=3) + Group Key: store_sales.ss_item_sk + -> Sort (cost=882965.15..882966.97 rows=727 width=31) (actual time=13595.277..13598.039 rows=24717 loops=3) + Sort Key: store_sales.ss_item_sk + Sort Method: quicksort Memory: 2196kB + Worker 0: Sort Method: quicksort Memory: 2500kB + Worker 1: Sort Method: quicksort Memory: 2225kB + -> Hash Join (cost=39816.76..882930.60 rows=727 width=31) (actual time=341.813..13585.969 rows=24717 loops=3) + Hash Cond: (store_sales.ss_promo_sk = promotion.p_promo_sk) + -> Parallel Hash Join (cost=39792.17..882895.82 rows=780 width=39) (actual time=111.127..13347.954 rows=25586 loops=3) + Hash Cond: (store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..845457.60 rows=57230 width=47) (actual time=8.440..13057.808 rows=1839779 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=55) (actual time=5.724..11904.748 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=2.652..2.653 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=2.029..3.882 rows=183 loops=2) + Filter: (d_year = 2000) + Rows Removed by Filter: 36342 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=100.683..100.683 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11402 width=8) (actual time=0.164..145.882 rows=13720 loops=2) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 946680 + -> Hash (cost=18.50..18.50 rows=487 width=8) (actual time=230.640..230.641 rows=489 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 28kB + -> Seq Scan on promotion (cost=0.00..18.50 rows=487 width=8) (actual time=230.481..230.585 rows=489 loops=3) + Filter: (((p_channel_email)::text = 'N'::text) AND ((p_channel_event)::text = 'N'::text)) + Rows Removed by Filter: 11 +Planning Time: 0.305 ms +JIT: + Functions: 119 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.687 ms, Inlining 152.550 ms, Optimization 519.823 ms, Emission 330.049 ms, Total 1008.109 ms +Execution Time: 14102.908 ms",SUCCESS +27,28,TPCDS,Q8,"SELECT + s.s_store_name, + SUM(ss.ss_net_profit) AS sum_net_profit +FROM tpcds.store_sales ss +JOIN tpcds.store s + ON ss.ss_store_sk = s.s_store_sk +JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk +JOIN ( + SELECT ca_zip + FROM ( + SELECT SUBSTR(ca_zip, 1, 5) AS ca_zip + FROM tpcds.customer_address + WHERE SUBSTR(ca_zip, 1, 5) IN ( + '10338','56623','51423','26456','19500','65832', + '17178','68879','49935','49849','93956', + '71765','45100','50587','68389','41899', + '98316','56217','94686','59350','32857', + '14925','31266','37817','27519','20787', + '26967','49045','39397','32010','23144', + '53580','15491','74151','18442','51916', + '17730','22824','28290','21657','45460', + '39386','21133','35017','19894','21759', + '79293','86733','76777','41688','13810', + '49053','17992','13395','19869','40785', + '63897','65049','27388','94701','41482', + '97923','23951','88284','61718','94317', + '72294','63544','31306','41242','28830', + '75535','86189','88177','16147','12902', + '48271','54036','20936','27802','96741', + '70286','75710','16034','90285','22058', + '52590','40584','62441','64039','68999', + '64327','33844','52497','88495','25989', + '67814','13767','83194','99395','35524', + '89640','48834','51875','71073','25383', + '19129','57805','47962','61905','19557', + '74159','98032','13917','50936','47993', + '41606','17592','11470','28216','19732', + '97958','60997','85688','96863','16605', + '10898','31340','71340','72902','98949', + '74440','53057','30323','76166','27195', + '11204','32771','38189','83221','22295', + '15325','20844','65549','69207','71903', + '63929','56922','25733','75482','14986', + '79223','73692','98769','70275','33793', + '13057','30142','95737','30072','32097', + '25845','50282','19289','92221','59533', + '37375','29706','48186','22385','55809', + '17416','10592','55385','71829','91975', + '73557','38036','10448','95252','51386', + '14190','15247','39907','79438','78053', + '66623','27720','84139','74147','58637', + '11434','36573','10081','53536','41724', + '97898','36752','50384','87352','35696', + '69486','50026','27837','42592','58865', + '80523','53682','65423','77611','98529', + '13909','13727','52190','36152','48355', + '62496','16527','18143','98830','75198', + '73043','64043','63042','67797','50656', + '27700','60687','57905','94404','15733', + '80809','74562','84493','67977','11213', + '19125','84496','16435','97510','46040', + '33968','20256','42332','16480','54277', + '82819','93799','69101','57689','42821', + '68073','49342','46915','25825','92332', + '20219','96577','49463','19221','35814', + '64783','97303','52061','24357','58167', + '56286','64474','99847','53626','39703', + '24880','24365','50652','29611','90638', + '59246','27171','30483','11708','38630', + '81914','48269','11720','88662','68844', + '54838','93795','38102','33481','97546', + '49306','97216','49032','14270','72418', + '32540','53208','15588','29990','10407', + '92334','48543','51495','77996','53686', + '14827','30978','30482','86296','48869', + '59600','29495','24775','34645','19763', + '98602','20456','10468','13887','65714', + '74740','37096','96240','44111','54109', + '62693','87874','64295','62027','86027', + '54341','68582','67809','44159','97913', + '79150','38974','64754','73946','20840', + '16138','58939','20428','19890','70842', + '78648','55576','37267','40470','12957', + '57553','53593','34067','22555','79719', + '25809','28496','11083','87624','83622', + '84898','28678','14297','79461','22910', + '87129','49941','64817','93905','39721', + '81837','18753','86432','67821','66080', + '28246','13466','16363','56950','35446', + '58326','11760','33962','28399','45848', + '52560','66894','15169','20988','85925', + '38582','34825','94227','56758','24801', + '14128','14012','35824','49784' + ) + INTERSECT + SELECT ca_zip + FROM ( + SELECT + SUBSTR(ca_zip, 1, 5) AS ca_zip, + COUNT(*) AS cnt + FROM tpcds.customer_address ca + JOIN tpcds.customer c + ON ca.ca_address_sk = c.c_current_addr_sk + WHERE c.c_preferred_cust_flag = 'Y' + GROUP BY SUBSTR(ca_zip, 1, 5) + HAVING COUNT(*) > 10 + ) A1 + ) A2 +) V1 + ON SUBSTR(s.s_zip, 1, 2) = SUBSTR(V1.ca_zip, 1, 2) +WHERE + d.d_qoy = 1 + AND d.d_year = 1998 +GROUP BY + s.s_store_name +ORDER BY + s.s_store_name +LIMIT 10;","metropolitan_areas = customers.WHERE(ISIN(current_address.zip_code[:5], ( + '10338','56623','51423','26456','19500','65832', + '17178','68879','49935','49849','93956', + '71765','45100','50587','68389','41899', + '98316','56217','94686','59350','32857', + '14925','31266','37817','27519','20787', + '26967','49045','39397','32010','23144', + '53580','15491','74151','18442','51916', + '17730','22824','28290','21657','45460', + '39386','21133','35017','19894','21759', + '79293','86733','76777','41688','13810', + '49053','17992','13395','19869','40785', + '63897','65049','27388','94701','41482', + '97923','23951','88284','61718','94317', + '72294','63544','31306','41242','28830', + '75535','86189','88177','16147','12902', + '48271','54036','20936','27802','96741', + '70286','75710','16034','90285','22058', + '52590','40584','62441','64039','68999', + '64327','33844','52497','88495','25989', + '67814','13767','83194','99395','35524', + '89640','48834','51875','71073','25383', + '19129','57805','47962','61905','19557', + '74159','98032','13917','50936','47993', + '41606','17592','11470','28216','19732', + '97958','60997','85688','96863','16605', + '10898','31340','71340','72902','98949', + '74440','53057','30323','76166','27195', + '11204','32771','38189','83221','22295', + '15325','20844','65549','69207','71903', + '63929','56922','25733','75482','14986', + '79223','73692','98769','70275','33793', + '13057','30142','95737','30072','32097', + '25845','50282','19289','92221','59533', + '37375','29706','48186','22385','55809', + '17416','10592','55385','71829','91975', + '73557','38036','10448','95252','51386', + '14190','15247','39907','79438','78053', + '66623','27720','84139','74147','58637', + '11434','36573','10081','53536','41724', + '97898','36752','50384','87352','35696', + '69486','50026','27837','42592','58865', + '80523','53682','65423','77611','98529', + '13909','13727','52190','36152','48355', + '62496','16527','18143','98830','75198', + '73043','64043','63042','67797','50656', + '27700','60687','57905','94404','15733', + '80809','74562','84493','67977','11213', + '19125','84496','16435','97510','46040', + '33968','20256','42332','16480','54277', + '82819','93799','69101','57689','42821', + '68073','49342','46915','25825','92332', + '20219','96577','49463','19221','35814', + '64783','97303','52061','24357','58167', + '56286','64474','99847','53626','39703', + '24880','24365','50652','29611','90638', + '59246','27171','30483','11708','38630', + '81914','48269','11720','88662','68844', + '54838','93795','38102','33481','97546', + '49306','97216','49032','14270','72418', + '32540','53208','15588','29990','10407', + '92334','48543','51495','77996','53686', + '14827','30978','30482','86296','48869', + '59600','29495','24775','34645','19763', + '98602','20456','10468','13887','65714', + '74740','37096','96240','44111','54109', + '62693','87874','64295','62027','86027', + '54341','68582','67809','44159','97913', + '79150','38974','64754','73946','20840', + '16138','58939','20428','19890','70842', + '78648','55576','37267','40470','12957', + '57553','53593','34067','22555','79719', + '25809','28496','11083','87624','83622', + '84898','28678','14297','79461','22910', + '87129','49941','64817','93905','39721', + '81837','18753','86432','67821','66080', + '28246','13466','16363','56950','35446', + '58326','11760','33962','28399','45848', + '52560','66894','15169','20988','85925', + '38582','34825','94227','56758','24801', + '14128','14012','35824','49784' + )) + & (preferred_customer_flag == 'Y') +).CALCULATE( + zip_5=current_address.zip_code[:5] +).PARTITION( + name='zip_codes', by=zip_5 +).WHERE( + COUNT(customers) > 10 +) +preferred_customers = customers.WHERE(preferred_customer_flag == 'Y') +selected_store_sales = store_sales.WHERE( + (sold_date.quarter_of_year == 1) + & (sold_date.year == 1998) +) +result = stores.CALCULATE(store_zip=zip_code).WHERE( + HAS(CROSS(metropolitan_areas).WHERE(store_zip[:2]==zip_5[:2])) + & HAS(selected_store_sales) +).CALCULATE( + store_sum=SUM(selected_store_sales.net_profit) +).PARTITION( + name='store_names', by=name +).CALCULATE( + s_store_name=name, + sum_net_profit=SUM(stores.store_sum) +).TOP_K(10, by=name)","WITH _t3 AS ( + SELECT + SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) AS zip, + COUNT(*) AS n_rows + FROM tpcds.customer AS customer + LEFT JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + WHERE + SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) IN ('10338', '56623', '51423', '26456', '19500', '65832', '17178', '68879', '49935', '49849', '93956', '71765', '45100', '50587', '68389', '41899', '98316', '56217', '94686', '59350', '32857', '14925', '31266', '37817', '27519', '20787', '26967', '49045', '39397', '32010', '23144', '53580', '15491', '74151', '18442', '51916', '17730', '22824', '28290', '21657', '45460', '39386', '21133', '35017', '19894', '21759', '79293', '86733', '76777', '41688', '13810', '49053', '17992', '13395', '19869', '40785', '63897', '65049', '27388', '94701', '41482', '97923', '23951', '88284', '61718', '94317', '72294', '63544', '31306', '41242', '28830', '75535', '86189', '88177', '16147', '12902', '48271', '54036', '20936', '27802', '96741', '70286', '75710', '16034', '90285', '22058', '52590', '40584', '62441', '64039', '68999', '64327', '33844', '52497', '88495', '25989', '67814', '13767', '83194', '99395', '35524', '89640', '48834', '51875', '71073', '25383', '19129', '57805', '47962', '61905', '19557', '74159', '98032', '13917', '50936', '47993', '41606', '17592', '11470', '28216', '19732', '97958', '60997', '85688', '96863', '16605', '10898', '31340', '71340', '72902', '98949', '74440', '53057', '30323', '76166', '27195', '11204', '32771', '38189', '83221', '22295', '15325', '20844', '65549', '69207', '71903', '63929', '56922', '25733', '75482', '14986', '79223', '73692', '98769', '70275', '33793', '13057', '30142', '95737', '30072', '32097', '25845', '50282', '19289', '92221', '59533', '37375', '29706', '48186', '22385', '55809', '17416', '10592', '55385', '71829', '91975', '73557', '38036', '10448', '95252', '51386', '14190', '15247', '39907', '79438', '78053', '66623', '27720', '84139', '74147', '58637', '11434', '36573', '10081', '53536', '41724', '97898', '36752', '50384', '87352', '35696', '69486', '50026', '27837', '42592', '58865', '80523', '53682', '65423', '77611', '98529', '13909', '13727', '52190', '36152', '48355', '62496', '16527', '18143', '98830', '75198', '73043', '64043', '63042', '67797', '50656', '27700', '60687', '57905', '94404', '15733', '80809', '74562', '84493', '67977', '11213', '19125', '84496', '16435', '97510', '46040', '33968', '20256', '42332', '16480', '54277', '82819', '93799', '69101', '57689', '42821', '68073', '49342', '46915', '25825', '92332', '20219', '96577', '49463', '19221', '35814', '64783', '97303', '52061', '24357', '58167', '56286', '64474', '99847', '53626', '39703', '24880', '24365', '50652', '29611', '90638', '59246', '27171', '30483', '11708', '38630', '81914', '48269', '11720', '88662', '68844', '54838', '93795', '38102', '33481', '97546', '49306', '97216', '49032', '14270', '72418', '32540', '53208', '15588', '29990', '10407', '92334', '48543', '51495', '77996', '53686', '14827', '30978', '30482', '86296', '48869', '59600', '29495', '24775', '34645', '19763', '98602', '20456', '10468', '13887', '65714', '74740', '37096', '96240', '44111', '54109', '62693', '87874', '64295', '62027', '86027', '54341', '68582', '67809', '44159', '97913', '79150', '38974', '64754', '73946', '20840', '16138', '58939', '20428', '19890', '70842', '78648', '55576', '37267', '40470', '12957', '57553', '53593', '34067', '22555', '79719', '25809', '28496', '11083', '87624', '83622', '84898', '28678', '14297', '79461', '22910', '87129', '49941', '64817', '93905', '39721', '81837', '18753', '86432', '67821', '66080', '28246', '13466', '16363', '56950', '35446', '58326', '11760', '33962', '28399', '45848', '52560', '66894', '15169', '20988', '85925', '38582', '34825', '94227', '56758', '24801', '14128', '14012', '35824', '49784') + AND customer.c_preferred_cust_flag = 'Y' + GROUP BY + 1 +), _u_0 AS ( + SELECT + SUBSTRING(zip FROM 1 FOR 2) AS _u_1 + FROM _t3 + WHERE + n_rows > 10 + GROUP BY + 1 +), _t1 AS ( + SELECT + MAX(store.s_store_name) AS anything_s_store_name, + SUM(store_sales.ss_net_profit) AS sum_ss_net_profit + FROM tpcds.store AS store + LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = SUBSTRING(store.s_zip FROM 1 FOR 2) + JOIN tpcds.store_sales AS store_sales + ON store.s_store_sk = store_sales.ss_store_sk + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk + AND date_dim.d_qoy = 1 + AND date_dim.d_year = 1998 + WHERE + NOT _u_0._u_1 IS NULL + GROUP BY + store_sales.ss_store_sk +) +SELECT + anything_s_store_name AS s_store_name, + COALESCE(SUM(sum_ss_net_profit), 0) AS sum_net_profit +FROM _t1 +GROUP BY + 1 +ORDER BY + 1 NULLS FIRST +LIMIT 10",14.148420709999755,14.664676814999893,"Limit (cost=892966.86..893215.03 rows=10 width=36) (actual time=14137.463..14174.963 rows=8 loops=1) + -> GroupAggregate (cost=892966.86..893215.03 rows=10 width=36) (actual time=13668.657..13706.156 rows=8 loops=1) + Group Key: s.s_store_name + -> Sort (cost=892966.86..893049.54 rows=33073 width=10) (actual time=13662.167..13683.555 rows=192619 loops=1) + Sort Key: s.s_store_name + Sort Method: external merge Disk: 4112kB + -> Hash Join (cost=41457.74..890484.17 rows=33073 width=10) (actual time=577.269..13616.369 rows=192619 loops=1) + Hash Cond: (substr((s.s_zip)::text, 1, 2) = substr(a2.ca_zip, 1, 2)) + -> Gather (cost=3684.52..849817.06 rows=33073 width=16) (actual time=9.335..12861.041 rows=754280 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=2684.52..845509.76 rows=13780 width=16) (actual time=277.203..13238.077 rows=251427 loops=3) + Hash Cond: (ss.ss_store_sk = s.s_store_sk) + -> Parallel Hash Join (cost=2677.23..845310.57 rows=14425 width=14) (actual time=3.602..12911.976 rows=257466 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=22) (actual time=0.210..12018.970 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=54 width=8) (actual time=2.704..2.705 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=54 width=8) (actual time=3.985..8.035 rows=91 loops=1) + Filter: ((d_qoy = 1) AND (d_year = 1998)) + Rows Removed by Filter: 72958 + -> Hash (cost=6.02..6.02 rows=102 width=18) (actual time=273.452..273.452 rows=102 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 14kB + -> Seq Scan on store s (cost=0.00..6.02 rows=102 width=18) (actual time=273.375..273.428 rows=102 loops=3) + -> Hash (cost=37770.72..37770.72 rows=200 width=32) (actual time=567.902..570.353 rows=9 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Subquery Scan on a2 (cost=24507.25..37770.72 rows=200 width=32) (actual time=567.864..570.345 rows=9 loops=1) + -> HashSetOp Intersect (cost=24507.25..37770.72 rows=200 width=36) (actual time=567.856..570.336 rows=9 loops=1) + -> Append (cost=24507.25..37227.19 rows=217413 width=36) (actual time=521.059..569.662 rows=3229 loops=1) + -> Subquery Scan on ""*SELECT* 2"" (cost=24507.25..24571.94 rows=1078 width=36) (actual time=521.057..524.548 rows=2268 loops=1) + -> Subquery Scan on a1 (cost=24507.25..24561.16 rows=1078 width=32) (actual time=521.054..524.350 rows=2268 loops=1) + -> Finalize HashAggregate (cost=24507.25..24550.38 rows=1078 width=40) (actual time=521.050..524.157 rows=2268 loops=1) + Group Key: (substr((ca.ca_zip)::text, 1, 5)) + Filter: (count(*) > 10) + Batches: 1 Memory Usage: 721kB + Rows Removed by Filter: 2599 + -> Gather (cost=23787.46..24474.90 rows=6470 width=40) (actual time=516.609..520.655 rows=11214 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=22787.46..22827.90 rows=3235 width=40) (actual time=487.497..487.991 rows=3738 loops=3) + Group Key: substr((ca.ca_zip)::text, 1, 5) + Batches: 1 Memory Usage: 465kB + Worker 0: Batches: 1 Memory Usage: 465kB + Worker 1: Batches: 1 Memory Usage: 465kB + -> Parallel Hash Join (cost=15712.89..22292.77 rows=98938 width=32) (actual time=384.402..471.888 rows=78942 loops=3) + Hash Cond: (ca.ca_address_sk = c.c_current_addr_sk) + -> Parallel Seq Scan on customer_address ca (cost=0.00..5529.67 rows=104167 width=14) (actual time=0.507..49.628 rows=83333 loops=3) + -> Parallel Hash (cost=14476.17..14476.17 rows=98938 width=8) (actual time=382.993..382.994 rows=78942 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 11392kB + -> Parallel Seq Scan on customer c (cost=0.00..14476.17 rows=98938 width=8) (actual time=239.565..287.705 rows=78942 loops=3) + Filter: ((c_preferred_cust_flag)::text = 'Y'::text) + Rows Removed by Filter: 87725 + -> Subquery Scan on ""*SELECT* 1"" (cost=1.00..11568.19 rows=216335 width=36) (actual time=0.120..44.878 rows=961 loops=1) + -> Seq Scan on customer_address (cost=1.00..9404.84 rows=216335 width=32) (actual time=0.117..44.786 rows=961 loops=1) + Filter: (substr((ca_zip)::text, 1, 5) = ANY ('{10338,56623,51423,26456,19500,65832,17178,68879,49935,49849,93956,71765,45100,50587,68389,41899,98316,56217,94686,59350,32857,14925,31266,37817,27519,20787,26967,49045,39397,32010,23144,53580,15491,74151,18442,51916,17730,22824,28290,21657,45460,39386,21133,35017,19894,21759,79293,86733,76777,41688,13810,49053,17992,13395,19869,40785,63897,65049,27388,94701,41482,97923,23951,88284,61718,94317,72294,63544,31306,41242,28830,75535,86189,88177,16147,12902,48271,54036,20936,27802,96741,70286,75710,16034,90285,22058,52590,40584,62441,64039,68999,64327,33844,52497,88495,25989,67814,13767,83194,99395,35524,89640,48834,51875,71073,25383,19129,57805,47962,61905,19557,74159,98032,13917,50936,47993,41606,17592,11470,28216,19732,97958,60997,85688,96863,16605,10898,31340,71340,72902,98949,74440,53057,30323,76166,27195,11204,32771,38189,83221,22295,15325,20844,65549,69207,71903,63929,56922,25733,75482,14986,79223,73692,98769,70275,33793,13057,30142,95737,30072,32097,25845,50282,19289,92221,59533,37375,29706,48186,22385,55809,17416,10592,55385,71829,91975,73557,38036,10448,95252,51386,14190,15247,39907,79438,78053,66623,27720,84139,74147,58637,11434,36573,10081,53536,41724,97898,36752,50384,87352,35696,69486,50026,27837,42592,58865,80523,53682,65423,77611,98529,13909,13727,52190,36152,48355,62496,16527,18143,98830,75198,73043,64043,63042,67797,50656,27700,60687,57905,94404,15733,80809,74562,84493,67977,11213,19125,84496,16435,97510,46040,33968,20256,42332,16480,54277,82819,93799,69101,57689,42821,68073,49342,46915,25825,92332,20219,96577,49463,19221,35814,64783,97303,52061,24357,58167,56286,64474,99847,53626,39703,24880,24365,50652,29611,90638,59246,27171,30483,11708,38630,81914,48269,11720,88662,68844,54838,93795,38102,33481,97546,49306,97216,49032,14270,72418,32540,53208,15588,29990,10407,92334,48543,51495,77996,53686,14827,30978,30482,86296,48869,59600,29495,24775,34645,19763,98602,20456,10468,13887,65714,74740,37096,96240,44111,54109,62693,87874,64295,62027,86027,54341,68582,67809,44159,97913,79150,38974,64754,73946,20840,16138,58939,20428,19890,70842,78648,55576,37267,40470,12957,57553,53593,34067,22555,79719,25809,28496,11083,87624,83622,84898,28678,14297,79461,22910,87129,49941,64817,93905,39721,81837,18753,86432,67821,66080,28246,13466,16363,56950,35446,58326,11760,33962,28399,45848,52560,66894,15169,20988,85925,38582,34825,94227,56758,24801,14128,14012,35824,49784}'::text[])) + Rows Removed by Filter: 249039 +Planning Time: 0.453 ms +JIT: + Functions: 135 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 10.008 ms, Inlining 480.149 ms, Optimization 941.329 ms, Emission 584.968 ms, Total 2016.454 ms +Execution Time: 14177.905 ms","Limit (cost=877631.97..877632.17 rows=10 width=64) (actual time=14307.817..14316.350 rows=8 loops=1) + -> GroupAggregate (cost=877631.97..877632.99 rows=51 width=64) (actual time=13756.047..13764.579 rows=8 loops=1) + Group Key: _t1.anything_s_store_name + -> Sort (cost=877631.97..877632.10 rows=51 width=64) (actual time=13756.030..13764.557 rows=13 loops=1) + Sort Key: _t1.anything_s_store_name NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> Subquery Scan on _t1 (cost=872950.79..877630.53 rows=51 width=64) (actual time=13578.421..13764.535 rows=13 loops=1) + -> GroupAggregate (cost=872950.79..877630.02 rows=51 width=72) (actual time=13578.417..13764.529 rows=13 loops=1) + Group Key: store_sales.ss_store_sk + -> Merge Join (cost=872950.79..877381.33 rows=33073 width=18) (actual time=13570.710..13740.678 rows=192619 loops=1) + Merge Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Gather Merge (cost=847307.09..851339.16 rows=34620 width=14) (actual time=13165.451..13276.259 rows=754281 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=846307.07..846343.13 rows=14425 width=14) (actual time=13146.833..13170.668 rows=252913 loops=3) + Sort Key: store_sales.ss_store_sk + Sort Method: external merge Disk: 6952kB + Worker 0: Sort Method: external merge Disk: 6248kB + Worker 1: Sort Method: external merge Disk: 6200kB + -> Parallel Hash Join (cost=2677.23..845310.57 rows=14425 width=14) (actual time=151.836..13080.983 rows=257466 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=22) (actual time=0.203..12060.888 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=54 width=8) (actual time=2.004..2.004 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=54 width=8) (actual time=3.080..5.936 rows=91 loops=1) + Filter: ((d_qoy = 1) AND (d_year = 1998)) + Rows Removed by Filter: 72958 + -> Sort (cost=25643.70..25643.95 rows=102 width=12) (actual time=400.422..408.380 rows=192635 loops=1) + Sort Key: store.s_store_sk + Sort Method: quicksort Memory: 26kB + -> Hash Join (cost=25633.98..25640.30 rows=102 width=12) (actual time=400.310..401.022 rows=29 loops=1) + Hash Cond: (SUBSTRING(store.s_zip FROM 1 FOR 2) = (SUBSTRING(_t3.zip FROM 1 FOR 2))) + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=18) (actual time=0.009..0.069 rows=102 loops=1) + -> Hash (cost=25631.48..25631.48 rows=200 width=32) (actual time=400.280..400.892 rows=8 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Group (cost=25625.59..25631.48 rows=200 width=32) (actual time=400.266..400.884 rows=8 loops=1) + Group Key: (SUBSTRING(_t3.zip FROM 1 FOR 2)) + -> Sort (cost=25625.59..25628.29 rows=1078 width=32) (actual time=400.260..400.872 rows=9 loops=1) + Sort Key: (SUBSTRING(_t3.zip FROM 1 FOR 2)) + Sort Method: quicksort Memory: 25kB + -> Subquery Scan on _t3 (cost=25514.69..25571.29 rows=1078 width=32) (actual time=400.232..400.859 rows=9 loops=1) + -> Finalize HashAggregate (cost=25514.69..25557.82 rows=1078 width=40) (actual time=400.228..400.852 rows=9 loops=1) + Group Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) + Filter: (count(*) > 10) + Batches: 1 Memory Usage: 121kB + Rows Removed by Filter: 7 + -> Gather (cost=24794.90..25482.34 rows=6470 width=40) (actual time=399.990..400.803 rows=41 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=23794.90..23835.34 rows=3235 width=40) (actual time=386.028..386.042 rows=14 loops=3) + Group Key: SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) + Batches: 1 Memory Usage: 121kB + Worker 0: Batches: 1 Memory Usage: 121kB + Worker 1: Batches: 1 Memory Usage: 121kB + -> Parallel Hash Join (cost=7953.86..23368.96 rows=85187 width=32) (actual time=257.688..385.843 rows=316 loops=3) + Hash Cond: (customer.c_current_addr_sk = customer_address.ca_address_sk) + -> Parallel Seq Scan on customer (cost=0.00..14476.17 rows=98938 width=8) (actual time=0.261..120.717 rows=78942 loops=3) + Filter: ((c_preferred_cust_flag)::text = 'Y'::text) + Rows Removed by Filter: 87725 + -> Parallel Hash (cost=6832.75..6832.75 rows=89689 width=14) (actual time=256.140..256.140 rows=320 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 2112kB + -> Parallel Seq Scan on customer_address (cost=1.00..6832.75 rows=89689 width=14) (actual time=164.239..201.900 rows=320 loops=3) + Filter: ((SUBSTRING(SUBSTRING(ca_zip FROM 1 FOR 5) FROM 1 FOR 2) IS NOT NULL) AND (SUBSTRING(ca_zip FROM 1 FOR 5) = ANY ('{10338,56623,51423,26456,19500,65832,17178,68879,49935,49849,93956,71765,45100,50587,68389,41899,98316,56217,94686,59350,32857,14925,31266,37817,27519,20787,26967,49045,39397,32010,23144,53580,15491,74151,18442,51916,17730,22824,28290,21657,45460,39386,21133,35017,19894,21759,79293,86733,76777,41688,13810,49053,17992,13395,19869,40785,63897,65049,27388,94701,41482,97923,23951,88284,61718,94317,72294,63544,31306,41242,28830,75535,86189,88177,16147,12902,48271,54036,20936,27802,96741,70286,75710,16034,90285,22058,52590,40584,62441,64039,68999,64327,33844,52497,88495,25989,67814,13767,83194,99395,35524,89640,48834,51875,71073,25383,19129,57805,47962,61905,19557,74159,98032,13917,50936,47993,41606,17592,11470,28216,19732,97958,60997,85688,96863,16605,10898,31340,71340,72902,98949,74440,53057,30323,76166,27195,11204,32771,38189,83221,22295,15325,20844,65549,69207,71903,63929,56922,25733,75482,14986,79223,73692,98769,70275,33793,13057,30142,95737,30072,32097,25845,50282,19289,92221,59533,37375,29706,48186,22385,55809,17416,10592,55385,71829,91975,73557,38036,10448,95252,51386,14190,15247,39907,79438,78053,66623,27720,84139,74147,58637,11434,36573,10081,53536,41724,97898,36752,50384,87352,35696,69486,50026,27837,42592,58865,80523,53682,65423,77611,98529,13909,13727,52190,36152,48355,62496,16527,18143,98830,75198,73043,64043,63042,67797,50656,27700,60687,57905,94404,15733,80809,74562,84493,67977,11213,19125,84496,16435,97510,46040,33968,20256,42332,16480,54277,82819,93799,69101,57689,42821,68073,49342,46915,25825,92332,20219,96577,49463,19221,35814,64783,97303,52061,24357,58167,56286,64474,99847,53626,39703,24880,24365,50652,29611,90638,59246,27171,30483,11708,38630,81914,48269,11720,88662,68844,54838,93795,38102,33481,97546,49306,97216,49032,14270,72418,32540,53208,15588,29990,10407,92334,48543,51495,77996,53686,14827,30978,30482,86296,48869,59600,29495,24775,34645,19763,98602,20456,10468,13887,65714,74740,37096,96240,44111,54109,62693,87874,64295,62027,86027,54341,68582,67809,44159,97913,79150,38974,64754,73946,20840,16138,58939,20428,19890,70842,78648,55576,37267,40470,12957,57553,53593,34067,22555,79719,25809,28496,11083,87624,83622,84898,28678,14297,79461,22910,87129,49941,64817,93905,39721,81837,18753,86432,67821,66080,28246,13466,16363,56950,35446,58326,11760,33962,28399,45848,52560,66894,15169,20988,85925,38582,34825,94227,56758,24801,14128,14012,35824,49784}'::text[]))) + Rows Removed by Filter: 83013 +Planning Time: 0.663 ms +JIT: + Functions: 122 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.954 ms, Inlining 277.160 ms, Optimization 744.312 ms, Emission 470.415 ms, Total 1498.841 ms +Execution Time: 14319.887 ms",SUCCESS +28,29,TPCDS,Q9,"SELECT + CASE + WHEN ( + SELECT COUNT(*) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 1 AND 20 + ) > 74129 + THEN ( + SELECT AVG(ss_ext_discount_amt) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 1 AND 20 + ) + ELSE ( + SELECT AVG(ss_net_paid) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 1 AND 20 + ) + END AS bucket1, + CASE + WHEN ( + SELECT COUNT(*) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 21 AND 40 + ) > 122840 + THEN ( + SELECT AVG(ss_ext_discount_amt) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 21 AND 40 + ) + ELSE ( + SELECT AVG(ss_net_paid) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 21 AND 40 + ) + END AS bucket2, + CASE + WHEN ( + SELECT COUNT(*) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 41 AND 60 + ) > 56580 + THEN ( + SELECT AVG(ss_ext_discount_amt) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 41 AND 60 + ) + ELSE ( + SELECT AVG(ss_net_paid) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 41 AND 60 + ) + END AS bucket3, + CASE + WHEN ( + SELECT COUNT(*) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 61 AND 80 + ) > 10097 + THEN ( + SELECT AVG(ss_ext_discount_amt) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 61 AND 80 + ) + ELSE ( + SELECT AVG(ss_net_paid) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 61 AND 80 + ) + END AS bucket4, + CASE + WHEN ( + SELECT COUNT(*) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 81 AND 100 + ) > 165306 + THEN ( + SELECT AVG(ss_ext_discount_amt) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 81 AND 100 + ) + ELSE ( + SELECT AVG(ss_net_paid) + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 81 AND 100 + ) + END AS bucket5 +FROM tpcds.reason +WHERE r_reason_sk = 1;","bucket1_sales = store_sales.WHERE(MONOTONIC(1, quantity, 20)) +bucket2_sales = store_sales.WHERE(MONOTONIC(21, quantity, 40)) +bucket3_sales = store_sales.WHERE(MONOTONIC(41, quantity, 60)) +bucket4_sales = store_sales.WHERE(MONOTONIC(61, quantity, 80)) +bucket5_sales = store_sales.WHERE(MONOTONIC(81, quantity, 100)) + +result = TPCDS.CALCULATE( + bucket1=IFF(COUNT(bucket1_sales) > 74129, AVG(bucket1_sales.ext_discount_amount), AVG(bucket1_sales.net_paid)), + bucket2=IFF(COUNT(bucket2_sales) > 122840, AVG(bucket2_sales.ext_discount_amount), AVG(bucket2_sales.net_paid)), + bucket3=IFF(COUNT(bucket3_sales) > 56580, AVG(bucket3_sales.ext_discount_amount), AVG(bucket3_sales.net_paid)), + bucket4=IFF(COUNT(bucket4_sales) > 10097, AVG(bucket4_sales.ext_discount_amount), AVG(bucket4_sales.net_paid)), + bucket5=IFF(COUNT(bucket5_sales) > 165306, AVG(bucket5_sales.ext_discount_amount), AVG(bucket5_sales.net_paid)) +)","WITH _s0 AS ( + SELECT + AVG(CAST(ss_ext_discount_amt AS DECIMAL)) AS avg_ss_ext_discount_amt, + AVG(CAST(ss_net_paid AS DECIMAL)) AS avg_ss_net_paid, + COUNT(*) AS n_rows + FROM tpcds.store_sales + WHERE + ss_quantity <= 20 AND ss_quantity >= 1 +), _s1 AS ( + SELECT + AVG(CAST(ss_ext_discount_amt AS DECIMAL)) AS avg_ss_ext_discount_amt, + AVG(CAST(ss_net_paid AS DECIMAL)) AS avg_ss_net_paid, + COUNT(*) AS n_rows + FROM tpcds.store_sales + WHERE + ss_quantity <= 40 AND ss_quantity >= 21 +), _s3 AS ( + SELECT + AVG(CAST(ss_ext_discount_amt AS DECIMAL)) AS avg_ss_ext_discount_amt, + AVG(CAST(ss_net_paid AS DECIMAL)) AS avg_ss_net_paid, + COUNT(*) AS n_rows + FROM tpcds.store_sales + WHERE + ss_quantity <= 60 AND ss_quantity >= 41 +), _s5 AS ( + SELECT + AVG(CAST(ss_ext_discount_amt AS DECIMAL)) AS avg_ss_ext_discount_amt, + AVG(CAST(ss_net_paid AS DECIMAL)) AS avg_ss_net_paid, + COUNT(*) AS n_rows + FROM tpcds.store_sales + WHERE + ss_quantity <= 80 AND ss_quantity >= 61 +), _s7 AS ( + SELECT + AVG(CAST(ss_ext_discount_amt AS DECIMAL)) AS avg_ss_ext_discount_amt, + AVG(CAST(ss_net_paid AS DECIMAL)) AS avg_ss_net_paid, + COUNT(*) AS n_rows + FROM tpcds.store_sales + WHERE + ss_quantity <= 100 AND ss_quantity >= 81 +) +SELECT + CASE + WHEN _s0.n_rows > 74129 + THEN _s0.avg_ss_ext_discount_amt + ELSE _s0.avg_ss_net_paid + END AS bucket1, + CASE + WHEN _s1.n_rows > 122840 + THEN _s1.avg_ss_ext_discount_amt + ELSE _s1.avg_ss_net_paid + END AS bucket2, + CASE + WHEN _s3.n_rows > 56580 + THEN _s3.avg_ss_ext_discount_amt + ELSE _s3.avg_ss_net_paid + END AS bucket3, + CASE + WHEN _s5.n_rows > 10097 + THEN _s5.avg_ss_ext_discount_amt + ELSE _s5.avg_ss_net_paid + END AS bucket4, + CASE + WHEN _s7.n_rows > 165306 + THEN _s7.avg_ss_ext_discount_amt + ELSE _s7.avg_ss_net_paid + END AS bucket5 +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 +CROSS JOIN _s3 AS _s3 +CROSS JOIN _s5 AS _s5 +CROSS JOIN _s7 AS _s7",134.64906375100009,67.12777924800002,"Seq Scan on reason (cost=12964213.45..12964226.71 rows=1 width=160) (actual time=134446.178..134454.534 rows=1 loops=1) + Filter: (r_reason_sk = 1) + Rows Removed by Filter: 44 + InitPlan 1 (returns $1) + -> Finalize Aggregate (cost=864384.49..864384.50 rows=1 width=8) (actual time=13109.454..13109.554 rows=1 loops=1) + -> Gather (cost=864384.27..864384.48 rows=2 width=8) (actual time=13109.290..13109.537 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=8) (actual time=13095.318..13095.319 rows=1 loops=3) + -> Parallel Seq Scan on store_sales (cost=0.00..857549.82 rows=2333779 width=0) (actual time=69.366..12999.884 rows=1832739 loops=3) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + Rows Removed by Filter: 7767592 + InitPlan 2 (returns $3) + -> Finalize Aggregate (cost=864384.50..864384.51 rows=1 width=32) (actual time=13405.189..13405.241 rows=1 loops=1) + -> Gather (cost=864384.27..864384.48 rows=2 width=32) (actual time=13405.026..13405.221 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=32) (actual time=13390.408..13390.409 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..857549.82 rows=2333779 width=3) (actual time=89.507..13144.372 rows=1832739 loops=3) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + Rows Removed by Filter: 7767592 + InitPlan 3 (returns $5) + -> Finalize Aggregate (cost=864384.50..864384.51 rows=1 width=32) (never executed) + -> Gather (cost=864384.27..864384.48 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..857549.82 rows=2333779 width=6) (never executed) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + InitPlan 4 (returns $7) + -> Finalize Aggregate (cost=864112.47..864112.48 rows=1 width=8) (actual time=13384.969..13385.022 rows=1 loops=1) + -> Gather (cost=864112.25..864112.46 rows=2 width=8) (actual time=13384.791..13385.004 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863112.25..863112.26 rows=1 width=8) (actual time=13370.886..13370.887 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..857549.82 rows=2224971 width=0) (actual time=61.665..13274.677 rows=1832725 loops=3) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + Rows Removed by Filter: 7767605 + InitPlan 5 (returns $9) + -> Finalize Aggregate (cost=864112.48..864112.49 rows=1 width=32) (actual time=13377.616..13377.664 rows=1 loops=1) + -> Gather (cost=864112.25..864112.46 rows=2 width=32) (actual time=13377.459..13377.644 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863112.25..863112.26 rows=1 width=32) (actual time=13362.054..13362.054 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..857549.82 rows=2224971 width=3) (actual time=94.576..13118.198 rows=1832725 loops=3) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + Rows Removed by Filter: 7767605 + InitPlan 6 (returns $11) + -> Finalize Aggregate (cost=864112.48..864112.49 rows=1 width=32) (never executed) + -> Gather (cost=864112.25..864112.46 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863112.25..863112.26 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..857549.82 rows=2224971 width=6) (never executed) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + InitPlan 7 (returns $13) + -> Finalize Aggregate (cost=864243.48..864243.49 rows=1 width=8) (actual time=13379.886..13379.935 rows=1 loops=1) + -> Gather (cost=864243.26..864243.47 rows=2 width=8) (actual time=13379.725..13379.920 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863243.26..863243.27 rows=1 width=8) (actual time=13365.898..13365.899 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_6 (cost=0.00..857549.82 rows=2277375 width=0) (actual time=57.807..13272.352 rows=1834381 loops=3) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + Rows Removed by Filter: 7765949 + InitPlan 8 (returns $15) + -> Finalize Aggregate (cost=864243.49..864243.50 rows=1 width=32) (actual time=13402.725..13402.771 rows=1 loops=1) + -> Gather (cost=864243.26..864243.47 rows=2 width=32) (actual time=13402.566..13402.756 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863243.26..863243.27 rows=1 width=32) (actual time=13388.724..13388.725 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_7 (cost=0.00..857549.82 rows=2277375 width=3) (actual time=90.044..13142.644 rows=1834381 loops=3) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + Rows Removed by Filter: 7765949 + InitPlan 9 (returns $17) + -> Finalize Aggregate (cost=864243.49..864243.50 rows=1 width=32) (never executed) + -> Gather (cost=864243.26..864243.47 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863243.26..863243.27 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_8 (cost=0.00..857549.82 rows=2277375 width=6) (never executed) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + InitPlan 10 (returns $19) + -> Finalize Aggregate (cost=864384.49..864384.50 rows=1 width=8) (actual time=13358.497..13358.550 rows=1 loops=1) + -> Gather (cost=864384.27..864384.48 rows=2 width=8) (actual time=13358.341..13358.535 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=8) (actual time=13341.786..13341.787 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_9 (cost=0.00..857549.82 rows=2333779 width=0) (actual time=67.869..13247.135 rows=1835252 loops=3) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + Rows Removed by Filter: 7765079 + InitPlan 11 (returns $21) + -> Finalize Aggregate (cost=864384.50..864384.51 rows=1 width=32) (actual time=13381.760..13381.811 rows=1 loops=1) + -> Gather (cost=864384.27..864384.48 rows=2 width=32) (actual time=13381.595..13381.797 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=32) (actual time=13363.786..13363.787 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_10 (cost=0.00..857549.82 rows=2333779 width=3) (actual time=89.793..13116.085 rows=1835252 loops=3) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + Rows Removed by Filter: 7765079 + InitPlan 12 (returns $23) + -> Finalize Aggregate (cost=864384.50..864384.51 rows=1 width=32) (never executed) + -> Gather (cost=864384.27..864384.48 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863384.27..863384.28 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_11 (cost=0.00..857549.82 rows=2333779 width=6) (never executed) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + InitPlan 13 (returns $25) + -> Finalize Aggregate (cost=864279.48..864279.49 rows=1 width=8) (actual time=13361.241..13361.289 rows=1 loops=1) + -> Gather (cost=864279.26..864279.47 rows=2 width=8) (actual time=13361.076..13361.278 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863279.26..863279.27 rows=1 width=8) (actual time=13343.796..13343.797 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_12 (cost=0.00..857549.82 rows=2291776 width=0) (actual time=70.222..13248.017 rows=1833173 loops=3) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) + Rows Removed by Filter: 7767157 + InitPlan 14 (returns $27) + -> Finalize Aggregate (cost=864279.49..864279.50 rows=1 width=32) (actual time=13393.674..13401.519 rows=1 loops=1) + -> Gather (cost=864279.27..864279.48 rows=2 width=32) (actual time=13393.500..13401.492 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863279.27..863279.28 rows=1 width=32) (actual time=13377.043..13377.044 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_13 (cost=0.00..857549.82 rows=2291776 width=3) (actual time=92.493..13133.184 rows=1833173 loops=3) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) + Rows Removed by Filter: 7767157 + InitPlan 15 (returns $29) + -> Finalize Aggregate (cost=864279.49..864279.50 rows=1 width=32) (never executed) + -> Gather (cost=864279.27..864279.48 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863279.27..863279.28 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_14 (cost=0.00..857549.82 rows=2291776 width=6) (never executed) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) +Planning Time: 0.358 ms +JIT: + Functions: 193 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 14.430 ms, Inlining 1164.828 ms, Optimization 1152.181 ms, Emission 807.003 ms, Total 3138.442 ms +Execution Time: 134459.336 ms","Nested Loop (cost=4378712.95..4378713.10 rows=1 width=160) (actual time=66665.935..66673.090 rows=1 loops=1) + -> Nested Loop (cost=3502974.56..3502974.67 rows=1 width=288) (actual time=53321.054..53321.416 rows=1 loops=1) + -> Nested Loop (cost=2626921.15..2626921.23 rows=1 width=216) (actual time=39970.215..39970.515 rows=1 loops=1) + -> Nested Loop (cost=1751290.76..1751290.81 rows=1 width=144) (actual time=26606.181..26606.413 rows=1 loops=1) + -> Finalize Aggregate (cost=876053.41..876053.42 rows=1 width=72) (actual time=13249.305..13249.456 rows=1 loops=1) + -> Gather (cost=876053.17..876053.38 rows=2 width=72) (actual time=13249.140..13249.433 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=875053.17..875053.18 rows=1 width=72) (actual time=13235.959..13235.960 rows=1 loops=3) + -> Parallel Seq Scan on store_sales (cost=0.00..857549.82 rows=2333779 width=9) (actual time=330.510..12876.278 rows=1832739 loops=3) + Filter: ((ss_quantity <= 20) AND (ss_quantity >= 1)) + Rows Removed by Filter: 7767592 + -> Finalize Aggregate (cost=875237.35..875237.36 rows=1 width=72) (actual time=13356.866..13356.944 rows=1 loops=1) + -> Gather (cost=875237.11..875237.32 rows=2 width=72) (actual time=13356.701..13356.921 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874237.11..874237.12 rows=1 width=72) (actual time=13341.750..13341.751 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..857549.82 rows=2224971 width=9) (actual time=106.186..12973.933 rows=1832725 loops=3) + Filter: ((ss_quantity <= 40) AND (ss_quantity >= 21)) + Rows Removed by Filter: 7767605 + -> Finalize Aggregate (cost=875630.38..875630.39 rows=1 width=72) (actual time=13364.028..13364.095 rows=1 loops=1) + -> Gather (cost=875630.14..875630.35 rows=2 width=72) (actual time=13363.841..13364.076 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874630.14..874630.15 rows=1 width=72) (actual time=13349.151..13349.151 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..857549.82 rows=2277375 width=9) (actual time=108.068..12986.433 rows=1834381 loops=3) + Filter: ((ss_quantity <= 60) AND (ss_quantity >= 41)) + Rows Removed by Filter: 7765949 + -> Finalize Aggregate (cost=876053.41..876053.42 rows=1 width=72) (actual time=13350.830..13350.891 rows=1 loops=1) + -> Gather (cost=876053.17..876053.38 rows=2 width=72) (actual time=13350.666..13350.868 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=875053.17..875053.18 rows=1 width=72) (actual time=13334.056..13334.057 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..857549.82 rows=2333779 width=9) (actual time=112.905..12966.170 rows=1835252 loops=3) + Filter: ((ss_quantity <= 80) AND (ss_quantity >= 61)) + Rows Removed by Filter: 7765079 + -> Finalize Aggregate (cost=875738.39..875738.40 rows=1 width=72) (actual time=13344.869..13351.662 rows=1 loops=1) + -> Gather (cost=875738.15..875738.36 rows=2 width=72) (actual time=13344.699..13351.638 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874738.15..874738.16 rows=1 width=72) (actual time=13330.814..13330.814 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..857549.82 rows=2291776 width=9) (actual time=106.794..12957.927 rows=1833173 loops=3) + Filter: ((ss_quantity <= 100) AND (ss_quantity >= 81)) + Rows Removed by Filter: 7767157 +Planning Time: 0.277 ms +JIT: + Functions: 89 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 10.204 ms, Inlining 652.740 ms, Optimization 1023.867 ms, Emission 605.973 ms, Total 2292.783 ms +Execution Time: 66676.121 ms",SUCCESS +29,30,TPCDS,Q10,"SELECT + cd.cd_gender, + cd.cd_marital_status, + cd.cd_education_status, + COUNT(*) AS cnt1, + cd.cd_purchase_estimate, + COUNT(*) AS cnt2, + cd.cd_credit_rating, + COUNT(*) AS cnt3, + cd.cd_dep_count, + COUNT(*) AS cnt4, + cd.cd_dep_employed_count, + COUNT(*) AS cnt5, + cd.cd_dep_college_count, + COUNT(*) AS cnt6 +FROM tpcds.customer c +JOIN tpcds.customer_address ca + ON c.c_current_addr_sk = ca.ca_address_sk +JOIN tpcds.customer_demographics cd + ON cd.cd_demo_sk = c.c_current_cdemo_sk +WHERE + ca.ca_county IN ( + 'Rush County', + 'Toole County', + 'Jefferson County', + 'Dona Ana County', + 'La Porte County' + ) + AND EXISTS ( + SELECT 1 + FROM tpcds.store_sales ss + JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk + WHERE + ss.ss_customer_sk = c.c_customer_sk + AND d.d_year = 2002 + AND d.d_moy BETWEEN 1 AND 3 + ) + AND ( + EXISTS ( + SELECT 1 + FROM tpcds.web_sales ws + JOIN tpcds.date_dim d + ON ws.ws_sold_date_sk = d.d_date_sk + WHERE + ws.ws_bill_customer_sk = c.c_customer_sk + AND d.d_year = 2002 + AND d.d_moy BETWEEN 1 AND 3 + ) + OR EXISTS ( + SELECT 1 + FROM tpcds.catalog_sales cs + JOIN tpcds.date_dim d + ON cs.cs_sold_date_sk = d.d_date_sk + WHERE + cs.cs_ship_customer_sk = c.c_customer_sk + AND d.d_year = 2002 + AND d.d_moy BETWEEN 1 AND 3 + ) + ) +GROUP BY + cd.cd_gender, + cd.cd_marital_status, + cd.cd_education_status, + cd.cd_purchase_estimate, + cd.cd_credit_rating, + cd.cd_dep_count, + cd.cd_dep_employed_count, + cd.cd_dep_college_count +ORDER BY + cd.cd_gender, + cd.cd_marital_status, + cd.cd_education_status, + cd.cd_purchase_estimate, + cd.cd_credit_rating, + cd.cd_dep_count, + cd.cd_dep_employed_count, + cd.cd_dep_college_count +LIMIT 10;","selected_store_sales = store_sales_as_bill_customer.WHERE( + (sold_date.year == 2002) + & (MONOTONIC(1, sold_date.month_of_year, 3)) +) + +selected_web_sales = web_sales_as_bill_customer.WHERE( + (sold_date.year == 2002) + & (MONOTONIC(1, sold_date.month_of_year, 3)) +) + +selected_cat_sales = catalog_sales_as_ship_customer.WHERE( + (sold_date.year == 2002) + & (MONOTONIC(1, sold_date.month_of_year, 3)) +) + +customers_in_counties = customers.WHERE( + HAS(current_address) & + ISIN(current_address.county, ('Rush County', 'Toole County', 'Jefferson County', + 'Dona Ana County', 'La Porte County')) + & (HAS(selected_store_sales) & (HAS(selected_web_sales) | HAS(selected_cat_sales))) + & HAS(current_demographics) +) + +result = customers_in_counties.CALCULATE( + gender=current_demographics.gender, + marital_status=current_demographics.marital_status, + education_status=current_demographics.education_status, + purchase_estimate=current_demographics.purchase_estimate, + credit_rating=current_demographics.credit_rating, + dep_count=current_demographics.dependent_count, + dep_employed_count=current_demographics.employed_dependent_count, + dep_college_count=current_demographics.college_dependent_count +).PARTITION( + name='demographics', by=( + gender, + marital_status, + education_status, + purchase_estimate, + credit_rating, + dep_count, + dep_employed_count, + dep_college_count + ) +).CALCULATE( + cd_gender=gender, + cd_marital_status=marital_status, + cd_education_status=education_status, + cnt1=COUNT(customers), + cd_purchase_estimate=purchase_estimate, + cnt2=COUNT(customers), + cd_credit_rating=credit_rating, + cnt3=COUNT(customers), + cd_dep_count=dep_count, + cnt4=COUNT(customers), + cd_dep_employed_count=dep_employed_count, + cnt5=COUNT(customers), + cd_dep_college_count=dep_college_count, + cnt6=COUNT(customers) +).TOP_K(10, by=( + cd_gender, + cd_marital_status, + cd_education_status, + cd_purchase_estimate, + cd_credit_rating, + cd_dep_count, + cd_dep_employed_count, + cd_dep_college_count + ) +)","WITH _t5 AS ( + SELECT + d_date_sk, + d_moy, + d_year + FROM tpcds.date_dim + WHERE + d_moy <= 3 AND d_moy >= 1 AND d_year = 2002 +), _u_0 AS ( + SELECT + store_sales.ss_customer_sk AS _u_1 + FROM tpcds.store_sales AS store_sales + JOIN _t5 AS _t5 + ON _t5.d_date_sk = store_sales.ss_sold_date_sk + GROUP BY + 1 +), _s9 AS ( + SELECT + web_sales.ws_bill_customer_sk + FROM tpcds.web_sales AS web_sales + JOIN _t5 AS _t6 + ON _t6.d_date_sk = web_sales.ws_sold_date_sk +), _s12 AS ( + SELECT + customer.c_customer_sk AS ws_bill_customer_sk, + MAX(customer.c_current_cdemo_sk) AS anything_c_current_cdemo_sk, + COUNT(_s9.ws_bill_customer_sk) AS count_ws_bill_customer_sk + FROM tpcds.customer AS customer + JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + AND customer_address.ca_county IN ('Rush County', 'Toole County', 'Jefferson County', 'Dona Ana County', 'La Porte County') + LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = customer.c_customer_sk + LEFT JOIN _s9 AS _s9 + ON _s9.ws_bill_customer_sk = customer.c_customer_sk + WHERE + NOT _u_0._u_1 IS NULL + GROUP BY + 1 +), _s13 AS ( + SELECT + catalog_sales.cs_ship_customer_sk + FROM tpcds.catalog_sales AS catalog_sales + JOIN _t5 AS _t7 + ON _t7.d_date_sk = catalog_sales.cs_sold_date_sk +), _t1 AS ( + SELECT + MAX(_s12.anything_c_current_cdemo_sk) AS anything_anything_c_current_cdemo_sk, + COUNT(_s13.cs_ship_customer_sk) AS count_cs_ship_customer_sk, + MAX(NULLIF(_s12.count_ws_bill_customer_sk, 0)) AS n_rows + FROM _s12 AS _s12 + LEFT JOIN _s13 AS _s13 + ON _s12.ws_bill_customer_sk = _s13.cs_ship_customer_sk + GROUP BY + _s12.ws_bill_customer_sk +) +SELECT + customer_demographics.cd_gender, + customer_demographics.cd_marital_status, + customer_demographics.cd_education_status, + COUNT(*) AS cnt1, + customer_demographics.cd_purchase_estimate, + COUNT(*) AS cnt2, + customer_demographics.cd_credit_rating, + COUNT(*) AS cnt3, + customer_demographics.cd_dep_count, + COUNT(*) AS cnt4, + customer_demographics.cd_dep_employed_count, + COUNT(*) AS cnt5, + customer_demographics.cd_dep_college_count, + COUNT(*) AS cnt6 +FROM _t1 AS _t1 +JOIN tpcds.customer_demographics AS customer_demographics + ON _t1.anything_anything_c_current_cdemo_sk = customer_demographics.cd_demo_sk +WHERE + ( + NOT NULLIF(_t1.count_cs_ship_customer_sk, 0) IS NULL + AND NULLIF(_t1.count_cs_ship_customer_sk, 0) > 0 + ) + OR ( + NOT _t1.n_rows IS NULL AND _t1.n_rows > 0 + ) +GROUP BY + 1, + 11, + 13, + 2, + 3, + 5, + 7, + 9 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST, + 5 NULLS FIRST, + 7 NULLS FIRST, + 9 NULLS FIRST, + 11 NULLS FIRST, + 13 NULLS FIRST +LIMIT 10",63.325356029999966,30.086640948999957,"Limit (cost=174519.62..24321134029.16 rows=10 width=98) (actual time=90031.109..91653.083 rows=10 loops=1) + -> GroupAggregate (cost=174519.62..522900803974.61 rows=215 width=98) (actual time=89675.575..91297.545 rows=10 loops=1) + Group Key: cd.cd_gender, cd.cd_marital_status, cd.cd_education_status, cd.cd_purchase_estimate, cd.cd_credit_rating, cd.cd_dep_count, cd.cd_dep_employed_count, cd.cd_dep_college_count + -> Nested Loop (cost=174519.62..522900803967.63 rows=215 width=50) (actual time=89557.573..91297.483 rows=11 loops=1) + Join Filter: (c.c_current_cdemo_sk = cd.cd_demo_sk) + Rows Removed by Join Filter: 26862452 + -> Gather Merge (cost=170734.97..394443.78 rows=1920800 width=58) (actual time=3657.853..3874.834 rows=373090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=169734.95..171735.78 rows=800333 width=58) (actual time=3101.777..3222.217 rows=124771 loops=3) + Sort Key: cd.cd_gender, cd.cd_marital_status, cd.cd_education_status, cd.cd_purchase_estimate, cd.cd_credit_rating, cd.cd_dep_count, cd.cd_dep_employed_count, cd.cd_dep_college_count + Sort Method: external merge Disk: 66896kB + Worker 0: Sort Method: external merge Disk: 44384kB + Worker 1: Sort Method: external merge Disk: 37544kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..31075.33 rows=800333 width=58) (actual time=76.503..213.577 rows=640267 loops=3) + -> Materialize (cost=3784.65..522893984448.40 rows=223 width=8) (actual time=0.089..0.232 rows=72 loops=373090) + -> Nested Loop Semi Join (cost=3784.65..522893984447.28 rows=223 width=8) (actual time=33164.123..85400.467 rows=72 loops=1) + Join Filter: (c.c_customer_sk = ss.ss_customer_sk) + Rows Removed by Join Filter: 435660478 + -> Nested Loop (cost=0.00..522891383966.00 rows=3408 width=16) (actual time=15080.713..28645.874 rows=562 loops=1) + Join Filter: (c.c_current_addr_sk = ca.ca_address_sk) + Rows Removed by Join Filter: 136864499 + -> Seq Scan on customer_address ca (cost=0.00..8550.50 rows=2272 width=8) (actual time=0.362..55.463 rows=2319 loops=1) + Filter: ((ca_county)::text = ANY ('{""Rush County"",""Toole County"",""Jefferson County"",""Dona Ana County"",""La Porte County""}'::text[])) + Rows Removed by Filter: 247681 + -> Materialize (cost=0.00..522873604695.00 rows=375000 width=24) (actual time=6.400..10.186 rows=59019 loops=2319) + -> Seq Scan on customer c (cost=0.00..522873600622.00 rows=375000 width=24) (actual time=14839.624..15036.804 rows=59019 loops=1) + Filter: ((hashed SubPlan 2) OR (hashed SubPlan 4)) + Rows Removed by Filter: 440981 + SubPlan 2 + -> Gather (cost=3784.65..302973.08 rows=8965 width=8) (actual time=16.734..4705.383 rows=211863 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.65..301076.58 rows=3735 width=8) (actual time=120.923..4700.524 rows=70621 loops=3) + Hash Cond: (ws.ws_sold_date_sk = d_1.d_date_sk) + -> Parallel Seq Scan on web_sales ws (cost=0.00..287023.10 rows=2999110 width=16) (actual time=0.194..4380.659 rows=2399189 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=54 width=8) (actual time=5.128..5.128 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d_1 (cost=0.00..2783.97 rows=54 width=8) (actual time=12.678..15.312 rows=90 loops=1) + Filter: ((d_moy >= 1) AND (d_moy <= 3) AND (d_year = 2002)) + Rows Removed by Filter: 72959 + SubPlan 4 + -> Gather (cost=3784.65..599875.76 rows=17849 width=8) (actual time=8029.861..10037.701 rows=404796 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.65..597090.86 rows=7437 width=8) (actual time=8011.658..10030.218 rows=134932 loops=3) + Hash Cond: (cs.cs_sold_date_sk = d_2.d_date_sk) + -> Parallel Seq Scan on catalog_sales cs (cost=0.00..571759.33 rows=6000733 width=16) (actual time=0.228..9516.348 rows=4800420 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=54 width=8) (actual time=5.720..5.721 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d_2 (cost=0.00..2783.97 rows=54 width=8) (actual time=14.383..17.088 rows=90 loops=1) + Filter: ((d_moy >= 1) AND (d_moy <= 3) AND (d_year = 2002)) + Rows Removed by Filter: 72959 + -> Materialize (cost=3784.65..850013.61 rows=34244 width=8) (actual time=0.019..71.446 rows=775197 loops=562) + -> Gather (cost=3784.65..849842.39 rows=34244 width=8) (actual time=9.691..13500.709 rows=830670 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.65..845417.99 rows=14268 width=8) (actual time=100.261..13564.962 rows=276890 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=16) (actual time=0.206..12630.418 rows=9600330 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=54 width=8) (actual time=2.622..2.622 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2783.97 rows=54 width=8) (actual time=4.015..7.800 rows=90 loops=1) + Filter: ((d_moy >= 1) AND (d_moy <= 3) AND (d_year = 2002)) + Rows Removed by Filter: 72959 +Planning Time: 0.502 ms +JIT: + Functions: 153 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.826 ms, Inlining 535.021 ms, Optimization 588.090 ms, Emission 389.674 ms, Total 1520.610 ms +Execution Time: 91659.406 ms","Limit (cost=2243162.14..2243162.49 rows=10 width=98) (actual time=29521.074..29521.385 rows=10 loops=1) + CTE _t5 + -> Seq Scan on date_dim (cost=0.00..3310.36 rows=91 width=24) (actual time=3.087..5.867 rows=90 loops=1) + Filter: ((d_moy <= 3) AND (d_moy >= 1) AND (d_year = 2002)) + Rows Removed by Filter: 72959 + -> GroupAggregate (cost=2239851.78..2239855.67 rows=111 width=98) (actual time=29050.311..29050.621 rows=10 loops=1) + Group Key: customer_demographics.cd_gender, customer_demographics.cd_marital_status, customer_demographics.cd_education_status, customer_demographics.cd_purchase_estimate, customer_demographics.cd_credit_rating, customer_demographics.cd_dep_count, customer_demographics.cd_dep_employed_count, customer_demographics.cd_dep_college_count + -> Sort (cost=2239851.78..2239852.06 rows=111 width=50) (actual time=29050.278..29050.584 rows=11 loops=1) + Sort Key: customer_demographics.cd_gender NULLS FIRST, customer_demographics.cd_marital_status NULLS FIRST, customer_demographics.cd_education_status NULLS FIRST, customer_demographics.cd_purchase_estimate NULLS FIRST, customer_demographics.cd_credit_rating NULLS FIRST, customer_demographics.cd_dep_count NULLS FIRST, customer_demographics.cd_dep_employed_count NULLS FIRST, customer_demographics.cd_dep_college_count NULLS FIRST + Sort Method: quicksort Memory: 30kB + -> Hash Join (cost=2190363.90..2239848.01 rows=111 width=50) (actual time=28584.631..29050.478 rows=71 loops=1) + Hash Cond: (customer_demographics.cd_demo_sk = _t1.anything_anything_c_current_cdemo_sk) + -> Seq Scan on customer_demographics (cost=0.00..42280.00 rows=1920800 width=58) (actual time=0.237..350.211 rows=1920800 loops=1) + -> Hash (cost=2190362.51..2190362.51 rows=111 width=8) (actual time=28583.671..28583.976 rows=71 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 11kB + -> Subquery Scan on _t1 (cost=2190247.87..2190362.51 rows=111 width=8) (actual time=28583.442..28583.961 rows=72 loops=1) + -> GroupAggregate (cost=2190247.87..2190361.40 rows=111 width=32) (actual time=28583.440..28583.953 rows=72 loops=1) + Group Key: _s12.ws_bill_customer_sk + Filter: (((NULLIF(count(catalog_sales.cs_ship_customer_sk), 0) IS NOT NULL) AND (NULLIF(count(catalog_sales.cs_ship_customer_sk), 0) > 0)) OR ((max(NULLIF(_s12.count_ws_bill_customer_sk, 0)) IS NOT NULL) AND (max(NULLIF(_s12.count_ws_bill_customer_sk, 0)) > 0))) + Rows Removed by Filter: 500 + -> Sort (cost=2190247.87..2190266.13 rows=7302 width=32) (actual time=28583.402..28583.752 rows=1009 loops=1) + Sort Key: _s12.ws_bill_customer_sk + Sort Method: quicksort Memory: 75kB + -> Hash Right Join (cost=1471032.22..2189779.30 rows=7302 width=32) (actual time=26532.750..28583.524 rows=1009 loops=1) + Hash Cond: (catalog_sales.cs_ship_customer_sk = _s12.ws_bill_customer_sk) + -> Hash Join (cost=2.96..716884.73 rows=710559 width=8) (actual time=8004.368..10032.144 rows=404796 loops=1) + Hash Cond: (catalog_sales.cs_sold_date_sk = _t7.d_date_sk) + -> Seq Scan on catalog_sales (cost=0.00..655769.59 rows=14401759 width=16) (actual time=0.228..9135.107 rows=14401261 loops=1) + -> Hash (cost=1.82..1.82 rows=91 width=8) (actual time=0.027..0.027 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 _t7 (cost=0.00..1.82 rows=91 width=8) (actual time=0.008..0.015 rows=90 loops=1) + -> Hash (cost=1471017.59..1471017.59 rows=934 width=24) (actual time=18525.239..18525.540 rows=572 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Subquery Scan on _s12 (cost=1470989.57..1471017.59 rows=934 width=24) (actual time=18524.943..18525.466 rows=572 loops=1) + -> GroupAggregate (cost=1470989.57..1471008.25 rows=934 width=24) (actual time=18524.940..18525.424 rows=572 loops=1) + Group Key: customer.c_customer_sk + -> Sort (cost=1470989.57..1470991.90 rows=934 width=24) (actual time=18524.907..18525.243 rows=829 loops=1) + Sort Key: customer.c_customer_sk + Sort Method: quicksort Memory: 59kB + -> Hash Right Join (cost=1109994.75..1470943.49 rows=934 width=24) (actual time=13691.353..18525.051 rows=829 loops=1) + Hash Cond: (web_sales.ws_bill_customer_sk = customer.c_customer_sk) + -> Hash Join (cost=2.96..359597.88 rows=359229 width=8) (actual time=0.588..4959.777 rows=211863 loops=1) + Hash Cond: (web_sales.ws_sold_date_sk = _t6.d_date_sk) + -> Seq Scan on web_sales (cost=0.00..329010.64 rows=7197864 width=16) (actual time=0.196..4492.956 rows=7197566 loops=1) + -> Hash (cost=1.82..1.82 rows=91 width=8) (actual time=0.039..0.040 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 _t6 (cost=0.00..1.82 rows=91 width=8) (actual time=0.014..0.023 rows=90 loops=1) + -> Hash (cost=1109980.12..1109980.12 rows=934 width=16) (actual time=13550.373..13550.670 rows=572 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 35kB + -> Hash Join (cost=1094769.32..1109980.12 rows=934 width=16) (actual time=13515.943..13550.561 rows=572 loops=1) + Hash Cond: (customer.c_customer_sk = store_sales.ss_customer_sk) + -> Gather (cost=7192.55..22391.42 rows=4544 width=16) (actual time=218.831..252.811 rows=4651 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=6192.55..20937.02 rows=1893 width=16) (actual time=201.416..341.365 rows=1550 loops=3) + Hash Cond: (customer.c_current_addr_sk = customer_address.ca_address_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=24) (actual time=0.237..120.936 rows=166667 loops=3) + -> Parallel Hash (cost=6180.71..6180.71 rows=947 width=8) (actual time=200.607..200.608 rows=773 loops=3) + Buckets: 4096 Batches: 1 Memory Usage: 160kB + -> Parallel Seq Scan on customer_address (cost=0.00..6180.71 rows=947 width=8) (actual time=127.891..143.590 rows=773 loops=3) + Filter: ((ca_county)::text = ANY ('{""Rush County"",""Toole County"",""Jefferson County"",""Dona Ana County"",""La Porte County""}'::text[])) + Rows Removed by Filter: 82560 + -> Hash (cost=1086292.25..1086292.25 rows=102762 width=8) (actual time=13297.043..13297.045 rows=67514 loops=1) + Buckets: 131072 Batches: 1 Memory Usage: 3662kB + -> HashAggregate (cost=1085264.62..1086292.25 rows=102762 width=8) (actual time=13282.210..13289.835 rows=67514 loops=1) + Group Key: store_sales.ss_customer_sk + Batches: 1 Memory Usage: 5905kB + -> Hash Join (cost=2.96..1081983.74 rows=1312353 width=8) (actual time=6.681..13169.802 rows=811066 loops=1) + Hash Cond: (store_sales.ss_sold_date_sk = _t5.d_date_sk) + -> Seq Scan on store_sales (cost=0.00..965558.12 rows=27546436 width=16) (actual time=0.222..11158.737 rows=27504024 loops=1) + Filter: (ss_customer_sk IS NOT NULL) + Rows Removed by Filter: 1296967 + -> Hash (cost=1.82..1.82 rows=91 width=8) (actual time=5.906..5.907 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 (cost=0.00..1.82 rows=91 width=8) (actual time=3.092..5.890 rows=90 loops=1) +Planning Time: 0.667 ms +JIT: + Functions: 127 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.658 ms, Inlining 119.390 ms, Optimization 435.364 ms, Emission 299.588 ms, Total 860.000 ms +Execution Time: 29524.830 ms",SUCCESS +30,31,TPCDS,Q11,"WITH year_total AS ( + SELECT + c.c_customer_id AS customer_id, + c.c_first_name AS customer_first_name, + c.c_last_name AS customer_last_name, + c.c_preferred_cust_flag AS customer_preferred_cust_flag, + c.c_birth_country AS customer_birth_country, + c.c_login AS customer_login, + c.c_email_address AS customer_email_address, + d.d_year AS dyear, + SUM(ss.ss_ext_list_price - ss.ss_ext_discount_amt) AS year_total, + 's' AS sale_type + FROM tpcds.customer c + JOIN tpcds.store_sales ss + ON c.c_customer_sk = ss.ss_customer_sk + JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk + GROUP BY + c.c_customer_id, + c.c_first_name, + c.c_last_name, + c.c_preferred_cust_flag, + c.c_birth_country, + c.c_login, + c.c_email_address, + d.d_year + UNION ALL + SELECT + c.c_customer_id AS customer_id, + c.c_first_name AS customer_first_name, + c.c_last_name AS customer_last_name, + c.c_preferred_cust_flag AS customer_preferred_cust_flag, + c.c_birth_country AS customer_birth_country, + c.c_login AS customer_login, + c.c_email_address AS customer_email_address, + d.d_year AS dyear, + SUM(ws.ws_ext_list_price - ws.ws_ext_discount_amt) AS year_total, + 'w' AS sale_type + FROM tpcds.customer c + JOIN tpcds.web_sales ws + ON c.c_customer_sk = ws.ws_bill_customer_sk + JOIN tpcds.date_dim d + ON ws.ws_sold_date_sk = d.d_date_sk + GROUP BY + c.c_customer_id, + c.c_first_name, + c.c_last_name, + c.c_preferred_cust_flag, + c.c_birth_country, + c.c_login, + c.c_email_address, + d.d_year +) +SELECT + t_s_secyear.customer_id, + t_s_secyear.customer_first_name, + t_s_secyear.customer_last_name, + t_s_secyear.customer_login, + t_w_firstyear.year_total AS wb_1st_y_total, + t_w_secyear.year_total AS wb_2nd_y_total, + t_s_firstyear.year_total AS ss_1st_y_total, + t_s_secyear.year_total AS ss_2nd_y_total +FROM year_total t_s_firstyear +JOIN year_total t_s_secyear + ON t_s_secyear.customer_id = t_s_firstyear.customer_id +JOIN year_total t_w_firstyear + ON t_w_firstyear.customer_id = t_s_firstyear.customer_id +JOIN year_total t_w_secyear + ON t_w_secyear.customer_id = t_s_firstyear.customer_id +WHERE + t_s_firstyear.sale_type = 's' + AND t_s_secyear.sale_type = 's' + AND t_w_firstyear.sale_type = 'w' + AND t_w_secyear.sale_type = 'w' + AND t_s_firstyear.dyear = 2000 + AND t_s_secyear.dyear = 2001 + AND t_w_firstyear.dyear = 2000 + AND t_w_secyear.dyear = 2001 + AND t_s_firstyear.year_total > 0 + AND t_w_firstyear.year_total > 0 + AND ( + CASE + WHEN t_w_firstyear.year_total > 0 + THEN t_w_secyear.year_total / t_w_firstyear.year_total + ELSE 0.0 + END + ) > + ( + CASE + WHEN t_s_firstyear.year_total > 0 + THEN t_s_secyear.year_total / t_s_firstyear.year_total + ELSE 0.0 + END + ) +ORDER BY + t_s_secyear.customer_id, + t_s_secyear.customer_first_name, + t_s_secyear.customer_last_name, + t_s_secyear.customer_login +LIMIT 100;","customer_store_2000_sales = store_sales_as_bill_customer.WHERE( + sold_date.year==2000 +).CALCULATE( + total_sale=(ext_list_price - ext_discount_amount) +) +customer_store_2001_sales = store_sales_as_bill_customer.WHERE( + sold_date.year==2001 +).CALCULATE( + total_sale=(ext_list_price - ext_discount_amount) +) +customer_web_2000_sales = web_sales_as_bill_customer.WHERE( + sold_date.year==2000 +).CALCULATE( + total_sale=(ext_list_price - ext_discount_amount) +) +customer_web_2001_sales = web_sales_as_bill_customer.WHERE( + sold_date.year==2001 +).CALCULATE( + total_sale=(ext_list_price - ext_discount_amount) +) + +result = customers.WHERE( + HAS(customer_store_2000_sales) + & HAS(customer_store_2001_sales) + & HAS(customer_web_2000_sales) + & HAS(customer_web_2001_sales) +).CALCULATE( + customer_id=_id, + customer_first_name=first_name, + customer_last_name=last_name, + customer_login=login, + wb_1st_y_total=SUM(customer_web_2000_sales.total_sale), + wb_2nd_y_total=SUM(customer_web_2001_sales.total_sale), + ss_1st_y_total=SUM(customer_store_2000_sales.total_sale), + ss_2nd_y_total=SUM(customer_store_2001_sales.total_sale) +).WHERE( + (IFF(wb_1st_y_total > 0, wb_2nd_y_total/wb_1st_y_total, 0) > + IFF(ss_1st_y_total > 0, ss_2nd_y_total/ss_1st_y_total, 0)) +).TOP_K(100, by=(_id.ASC(), first_name, last_name, login))","WITH _s0 AS ( + SELECT + ss_customer_sk, + ss_ext_discount_amt, + ss_ext_list_price, + ss_sold_date_sk + FROM tpcds.store_sales +), _t4 AS ( + SELECT + d_date_sk, + d_year + FROM tpcds.date_dim + WHERE + d_year = 2000 +), _s6 AS ( + SELECT + _s0.ss_customer_sk AS c_customer_sk, + MAX(customer.c_customer_id) AS anything_c_customer_id, + MAX(customer.c_first_name) AS anything_c_first_name, + MAX(customer.c_last_name) AS anything_c_last_name, + MAX(customer.c_login) AS anything_c_login, + SUM(_s0.ss_ext_list_price - _s0.ss_ext_discount_amt) AS sum_total_sale + FROM tpcds.customer AS customer + JOIN _s0 AS _s0 + ON _s0.ss_customer_sk = customer.c_customer_sk + JOIN _t4 AS _t4 + ON _s0.ss_sold_date_sk = _t4.d_date_sk + GROUP BY + 1 +), _t5 AS ( + SELECT + d_date_sk, + d_year + FROM tpcds.date_dim + WHERE + d_year = 2001 +), _s10 AS ( + SELECT + _s4.ss_customer_sk AS c_customer_sk, + SUM(_s4.ss_ext_list_price - _s4.ss_ext_discount_amt) AS agg_1, + MAX(_s6.anything_c_customer_id) AS anything_anything_c_customer_id, + MAX(_s6.anything_c_first_name) AS anything_anything_c_first_name, + MAX(_s6.anything_c_last_name) AS anything_anything_c_last_name, + MAX(_s6.anything_c_login) AS anything_anything_c_login, + MAX(_s6.sum_total_sale) AS anything_sum_total_sale + FROM _s6 AS _s6 + JOIN _s0 AS _s4 + ON _s4.ss_customer_sk = _s6.c_customer_sk + JOIN _t5 AS _t5 + ON _s4.ss_sold_date_sk = _t5.d_date_sk + GROUP BY + 1 +), _s8 AS ( + SELECT + ws_bill_customer_sk, + ws_ext_discount_amt, + ws_ext_list_price, + ws_sold_date_sk + FROM tpcds.web_sales +), _s14 AS ( + SELECT + _s8.ws_bill_customer_sk AS c_customer_sk, + SUM(_s8.ws_ext_list_price - _s8.ws_ext_discount_amt) AS agg_2, + MAX(_s10.agg_1) AS anything_agg_1, + MAX(_s10.anything_anything_c_customer_id) AS anything_anything_anything_c_customer_id, + MAX(_s10.anything_anything_c_first_name) AS anything_anything_anything_c_first_name, + MAX(_s10.anything_anything_c_last_name) AS anything_anything_anything_c_last_name, + MAX(_s10.anything_anything_c_login) AS anything_anything_anything_c_login, + MAX(_s10.anything_sum_total_sale) AS anything_anything_sum_total_sale + FROM _s10 AS _s10 + JOIN _s8 AS _s8 + ON _s10.c_customer_sk = _s8.ws_bill_customer_sk + JOIN _t4 AS _t6 + ON _s8.ws_sold_date_sk = _t6.d_date_sk + GROUP BY + 1 +), _s15 AS ( + SELECT + _s12.ws_bill_customer_sk, + SUM(_s12.ws_ext_list_price - _s12.ws_ext_discount_amt) AS agg_3_0 + FROM _s8 AS _s12 + JOIN _t5 AS _t8 + ON _s12.ws_sold_date_sk = _t8.d_date_sk + GROUP BY + 1 +) +SELECT + _s14.anything_anything_anything_c_customer_id AS customer_id, + _s14.anything_anything_anything_c_first_name AS customer_first_name, + _s14.anything_anything_anything_c_last_name AS customer_last_name, + _s14.anything_anything_anything_c_login AS customer_login, + COALESCE(_s14.agg_2, 0) AS wb_1st_y_total, + COALESCE(_s15.agg_3_0, 0) AS wb_2nd_y_total, + COALESCE(_s14.anything_anything_sum_total_sale, 0) AS ss_1st_y_total, + COALESCE(_s14.anything_agg_1, 0) AS ss_2nd_y_total +FROM _s14 AS _s14 +JOIN _s15 AS _s15 + ON CASE + WHEN ( + NOT _s14.agg_2 IS NULL AND _s14.agg_2 > 0 + ) + THEN CAST(COALESCE(_s15.agg_3_0, 0) AS DOUBLE PRECISION) / COALESCE(_s14.agg_2, 0) + ELSE 0 + END > CASE + WHEN ( + NOT _s14.anything_anything_sum_total_sale IS NULL + AND _s14.anything_anything_sum_total_sale > 0 + ) + THEN CAST(COALESCE(_s14.anything_agg_1, 0) AS DOUBLE PRECISION) / COALESCE(_s14.anything_anything_sum_total_sale, 0) + ELSE 0 + END + AND _s14.c_customer_sk = _s15.ws_bill_customer_sk +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST, + 4 NULLS FIRST +LIMIT 100",850.9019782170003,47.644232835000366,"Limit (cost=11817197.28..11900903.59 rows=100 width=392) (actual time=365320.943..875144.701 rows=100 loops=1) + CTE year_total + -> Append (cost=4034333.82..10133171.88 rows=33484824 width=142) (actual time=70907.681..98872.436 rows=2079862 loops=1) + -> Finalize GroupAggregate (cost=4034333.82..7877645.52 rows=26290318 width=142) (actual time=70907.680..80943.975 rows=1545762 loops=1) + Group Key: c.c_customer_id, c.c_first_name, c.c_last_name, c.c_preferred_cust_flag, c.c_birth_country, c.c_login, c.c_email_address, d.d_year + -> Gather Merge (cost=4034333.82..7001301.60 rows=21908598 width=110) (actual time=70907.633..79725.849 rows=1610989 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=4033333.80..4471505.76 rows=10954299 width=110) (actual time=64330.225..71872.285 rows=536996 loops=3) + Group Key: c.c_customer_id, c.c_first_name, c.c_last_name, c.c_preferred_cust_flag, c.c_birth_country, c.c_login, c.c_email_address, d.d_year + -> Sort (cost=4033333.80..4060719.55 rows=10954299 width=88) (actual time=64330.170..67367.479 rows=8951983 loops=3) + Sort Key: c.c_customer_id, c.c_first_name, c.c_last_name, c.c_preferred_cust_flag, c.c_birth_country, c.c_login, c.c_email_address, d.d_year + Sort Method: external merge Disk: 761672kB + Worker 0: Sort Method: external merge Disk: 1186368kB + Worker 1: Sort Method: external merge Disk: 760416kB + -> Parallel Hash Join (cost=22203.32..1179959.73 rows=10954299 width=88) (actual time=15904.700..20866.671 rows=8951983 loops=3) + Hash Cond: (ss.ss_customer_sk = c.c_customer_sk) + -> Parallel Hash Join (cost=2998.82..912922.09 rows=11453680 width=26) (actual time=10.708..13399.952 rows=9168178 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=26) (actual time=0.293..11076.519 rows=9600330 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=16) (actual time=9.812..9.812 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4480kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2461.70 rows=42970 width=16) (actual time=0.021..4.129 rows=24350 loops=3) + -> Parallel Hash (cost=13955.33..13955.33 rows=208333 width=78) (actual time=464.137..464.138 rows=166667 loops=3) + Buckets: 131072 Batches: 8 Memory Usage: 8064kB + -> Parallel Seq Scan on customer c (cost=0.00..13955.33 rows=208333 width=78) (actual time=266.920..312.100 rows=166667 loops=3) + -> Finalize GroupAggregate (cost=1036356.46..2088102.24 rows=7194506 width=142) (actual time=13786.077..17788.729 rows=534100 loops=1) + Group Key: c_1.c_customer_id, c_1.c_first_name, c_1.c_last_name, c_1.c_preferred_cust_flag, c_1.c_birth_country, c_1.c_login, c_1.c_email_address, d_1.d_year + -> Gather Merge (cost=1036356.46..1848285.36 rows=5995422 width=110) (actual time=13786.052..17307.341 rows=536511 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1035356.44..1155264.88 rows=2997711 width=110) (actual time=13724.852..16736.265 rows=178837 loops=3) + Group Key: c_1.c_customer_id, c_1.c_first_name, c_1.c_last_name, c_1.c_preferred_cust_flag, c_1.c_birth_country, c_1.c_login, c_1.c_email_address, d_1.d_year + -> Sort (cost=1035356.44..1042850.72 rows=2997711 width=91) (actual time=13724.792..15520.708 rows=2398314 loops=3) + Sort Key: c_1.c_customer_id, c_1.c_first_name, c_1.c_last_name, c_1.c_preferred_cust_flag, c_1.c_birth_country, c_1.c_login, c_1.c_email_address, d_1.d_year + Sort Method: external merge Disk: 195672kB + Worker 0: Sort Method: external merge Disk: 194232kB + Worker 1: Sort Method: external merge Disk: 359480kB + -> Parallel Hash Join (cost=22203.32..405487.24 rows=2997711 width=91) (actual time=5209.841..5800.231 rows=2398314 loops=3) + Hash Cond: (ws.ws_bill_customer_sk = c_1.c_customer_sk) + -> Parallel Hash Join (cost=2998.82..318906.89 rows=2998510 width=29) (actual time=10.936..4182.370 rows=2398599 loops=3) + Hash Cond: (ws.ws_sold_date_sk = d_1.d_date_sk) + -> Parallel Seq Scan on web_sales ws (cost=0.00..287023.10 rows=2999110 width=29) (actual time=0.368..3549.021 rows=2399189 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=16) (actual time=9.936..9.937 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4512kB + -> Parallel Seq Scan on date_dim d_1 (cost=0.00..2461.70 rows=42970 width=16) (actual time=0.022..4.111 rows=24350 loops=3) + -> Parallel Hash (cost=13955.33..13955.33 rows=208333 width=78) (actual time=477.683..477.684 rows=166667 loops=3) + Buckets: 131072 Batches: 8 Memory Usage: 8032kB + -> Parallel Seq Scan on customer c_1 (cost=0.00..13955.33 rows=208333 width=78) (actual time=280.489..326.761 rows=166667 loops=3) + -> Incremental Sort (cost=1684025.40..3585832.75 rows=2272 width=392) (actual time=364331.575..874073.207 rows=100 loops=1) + Sort Key: t_s_secyear.customer_id, t_s_secyear.customer_first_name, t_s_secyear.customer_last_name, t_s_secyear.customer_login + Presorted Key: t_s_secyear.customer_id + Full-sort Groups: 4 Sort Method: quicksort Average Memory: 29kB Peak Memory: 29kB + -> Nested Loop (cost=1674322.47..3585760.34 rows=2272 width=392) (actual time=101662.363..874072.957 rows=101 loops=1) + Join Filter: (((t_s_secyear.customer_id)::text = (t_w_firstyear.customer_id)::text) AND (CASE WHEN (t_w_firstyear.year_total > '0'::numeric) THEN (t_w_secyear.year_total / t_w_firstyear.year_total) ELSE 0.0 END > CASE WHEN (t_s_firstyear.year_total > '0'::numeric) THEN (t_s_secyear.year_total / t_s_firstyear.year_total) ELSE 0.0 END)) + Rows Removed by Join Filter: 98698266 + -> Nested Loop (cost=1674322.47..2617199.15 rows=4888 width=460) (actual time=100791.723..589736.611 rows=919 loops=1) + Join Filter: ((t_s_firstyear.customer_id)::text = (t_s_secyear.customer_id)::text) + Rows Removed by Join Filter: 446961554 + -> Merge Join (cost=1674322.47..1674379.20 rows=3503 width=378) (actual time=100456.374..100473.325 rows=1447 loops=1) + Merge Cond: ((t_s_secyear.customer_id)::text = (t_w_secyear.customer_id)::text) + -> Sort (cost=837161.23..837163.33 rows=837 width=296) (actual time=100151.822..100155.915 rows=6624 loops=1) + Sort Key: t_s_secyear.customer_id + Sort Method: external merge Disk: 15208kB + -> CTE Scan on year_total t_s_secyear (cost=0.00..837120.60 rows=837 width=296) (actual time=70907.724..100015.335 rows=307975 loops=1) + Filter: ((sale_type = 's'::text) AND (dyear = 2001)) + Rows Removed by Filter: 1771887 + -> Sort (cost=837161.23..837163.33 rows=837 width=82) (actual time=304.498..306.816 rows=2360 loops=1) + Sort Key: t_w_secyear.customer_id + Sort Method: external sort Disk: 4160kB + -> CTE Scan on year_total t_w_secyear (cost=0.00..837120.60 rows=837 width=82) (actual time=176.106..239.585 rows=106184 loops=1) + Filter: ((sale_type = 'w'::text) AND (dyear = 2001)) + Rows Removed by Filter: 1973678 + -> CTE Scan on year_total t_s_firstyear (cost=0.00..920832.66 rows=279 width=82) (actual time=0.002..323.418 rows=308889 loops=1447) + Filter: ((year_total > '0'::numeric) AND (sale_type = 's'::text) AND (dyear = 2000)) + Rows Removed by Filter: 1769559 + -> CTE Scan on year_total t_w_firstyear (cost=0.00..920832.66 rows=279 width=82) (actual time=220.724..304.276 rows=107398 loops=919) + Filter: ((year_total > '0'::numeric) AND (sale_type = 'w'::text) AND (dyear = 2000)) + Rows Removed by Filter: 1971896 +Planning Time: 0.567 ms +JIT: + Functions: 178 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 18.151 ms, Inlining 330.262 ms, Optimization 1454.275 ms, Emission 847.120 ms, Total 2649.808 ms +Execution Time: 875213.494 ms","Limit (cost=10869541.09..10869541.26 rows=67 width=256) (actual time=54479.539..54479.564 rows=100 loops=1) + CTE _s0 + -> Seq Scan on store_sales (cost=0.00..965558.12 rows=28802212 width=26) (actual time=0.347..7578.567 rows=28800991 loops=1) + CTE _t4 + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=365 width=16) (actual time=2.501..4.887 rows=366 loops=1) + Filter: (d_year = 2000) + Rows Removed by Filter: 72683 + CTE _t5 + -> Seq Scan on date_dim date_dim_1 (cost=0.00..2945.11 rows=365 width=16) (actual time=2.523..4.980 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + CTE _s8 + -> Seq Scan on web_sales (cost=0.00..329010.64 rows=7197864 width=29) (actual time=0.273..1825.337 rows=7197566 loops=1) + -> Sort (cost=9569082.11..9569082.28 rows=67 width=256) (actual time=53727.124..53727.140 rows=100 loops=1) + Sort Key: (max(_s10.anything_anything_c_customer_id)) NULLS FIRST, (max(_s10.anything_anything_c_first_name)) NULLS FIRST, (max(_s10.anything_anything_c_last_name)) NULLS FIRST, (max(_s10.anything_anything_c_login)) NULLS FIRST + Sort Method: top-N heapsort Memory: 48kB + -> Hash Join (cost=9569075.05..9569080.08 rows=67 width=256) (actual time=53411.521..53724.753 rows=4331 loops=1) + Hash Cond: (_s8.ws_bill_customer_sk = _s15.ws_bill_customer_sk) + Join Filter: (CASE WHEN (((sum((_s8.ws_ext_list_price - _s8.ws_ext_discount_amt))) IS NOT NULL) AND ((sum((_s8.ws_ext_list_price - _s8.ws_ext_discount_amt))) > '0'::numeric)) THEN ((COALESCE(_s15.agg_3_0, '0'::numeric))::double precision / (COALESCE((sum((_s8.ws_ext_list_price - _s8.ws_ext_discount_amt))), '0'::numeric))::double precision) ELSE '0'::double precision END > CASE WHEN (((max(_s10.anything_sum_total_sale)) IS NOT NULL) AND ((max(_s10.anything_sum_total_sale)) > '0'::numeric)) THEN ((COALESCE((max(_s10.agg_1)), '0'::numeric))::double precision / (COALESCE((max(_s10.anything_sum_total_sale)), '0'::numeric))::double precision) ELSE '0'::double precision END) + Rows Removed by Join Filter: 4310 + -> HashAggregate (cost=8853318.58..8853321.08 rows=200 width=232) (actual time=48309.271..48608.524 rows=40913 loops=1) + Group Key: _s8.ws_bill_customer_sk + Batches: 5 Memory Usage: 7617kB Disk Usage: 36184kB + -> Hash Join (cost=7921244.68..8557756.29 rows=13136102 width=228) (actual time=45953.151..47998.863 rows=550891 loops=1) + Hash Cond: (_s8.ws_sold_date_sk = _t6.d_date_sk) + -> Hash Join (cost=7921232.82..8084484.87 rows=7197864 width=236) (actual time=45947.575..47768.575 rows=2745884 loops=1) + Hash Cond: (_s8.ws_bill_customer_sk = _s10.c_customer_sk) + -> CTE Scan on _s8 (cost=0.00..143957.28 rows=7197864 width=44) (actual time=0.033..560.922 rows=7197566 loops=1) + -> Hash (cost=7921230.32..7921230.32 rows=200 width=200) (actual time=45947.449..45947.457 rows=190292 loops=1) + Buckets: 131072 (originally 1024) Batches: 4 (originally 1) Memory Usage: 7169kB + -> Subquery Scan on _s10 (cost=7921225.82..7921230.32 rows=200 width=200) (actual time=44235.769..45904.456 rows=190292 loops=1) + -> HashAggregate (cost=7921225.82..7921228.32 rows=200 width=200) (actual time=44235.765..45891.105 rows=190292 loops=1) + Group Key: _s4.ss_customer_sk + Batches: 37 Memory Usage: 8385kB Disk Usage: 236432kB + -> Hash Join (cost=4322947.47..6869945.08 rows=52564037 width=196) (actual time=31783.004..42837.643 rows=3301970 loops=1) + Hash Cond: (_s4.ss_sold_date_sk = _t5.d_date_sk) + -> Hash Join (cost=4322935.60..4976187.77 rows=28802212 width=204) (actual time=31782.877..41388.650 rows=19103439 loops=1) + Hash Cond: (_s4.ss_customer_sk = _s6.c_customer_sk) + -> CTE Scan on _s0 _s4 (cost=0.00..576044.24 rows=28802212 width=44) (actual time=0.348..3964.349 rows=28800991 loops=1) + -> Hash (cost=4322933.10..4322933.10 rows=200 width=168) (actual time=31782.065..31782.069 rows=309098 loops=1) + Buckets: 131072 (originally 1024) Batches: 4 (originally 1) Memory Usage: 7393kB + -> Subquery Scan on _s6 (cost=4322928.60..4322933.10 rows=200 width=168) (actual time=29153.134..31715.929 rows=309098 loops=1) + -> HashAggregate (cost=4322928.60..4322931.10 rows=200 width=168) (actual time=29153.130..31694.039 rows=309098 loops=1) + Group Key: _s0.ss_customer_sk + Batches: 53 Memory Usage: 8361kB Disk Usage: 352016kB + -> Hash Join (cost=27040.86..3403057.96 rows=52564037 width=67) (actual time=193.848..27100.582 rows=5389360 loops=1) + Hash Cond: (_s0.ss_sold_date_sk = _t4.d_date_sk) + -> Hash Join (cost=27029.00..1509300.65 rows=28802212 width=75) (actual time=193.313..24900.489 rows=27504024 loops=1) + Hash Cond: (_s0.ss_customer_sk = customer.c_customer_sk) + -> CTE Scan on _s0 (cost=0.00..576044.24 rows=28802212 width=44) (actual time=0.002..15198.055 rows=28800991 loops=1) + -> Hash (cost=16872.00..16872.00 rows=500000 width=39) (actual time=193.187..193.188 rows=500000 loops=1) + Buckets: 131072 Batches: 8 Memory Usage: 5574kB + -> Seq Scan on customer (cost=0.00..16872.00 rows=500000 width=39) (actual time=0.201..98.180 rows=500000 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=0.064..0.064 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 (cost=0.00..7.30 rows=365 width=8) (actual time=0.003..0.027 rows=366 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=0.066..0.066 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 (cost=0.00..7.30 rows=365 width=8) (actual time=0.005..0.030 rows=365 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=4.988..4.989 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 _t6 (cost=0.00..7.30 rows=365 width=8) (actual time=2.505..4.952 rows=366 loops=1) + -> Hash (cost=715753.97..715753.97 rows=200 width=40) (actual time=5102.205..5102.207 rows=106184 loops=1) + Buckets: 131072 (originally 1024) Batches: 1 (originally 1) Memory Usage: 6805kB + -> Subquery Scan on _s15 (cost=715749.47..715753.97 rows=200 width=40) (actual time=4757.474..5091.184 rows=106185 loops=1) + -> HashAggregate (cost=715749.47..715751.97 rows=200 width=40) (actual time=4757.470..5083.911 rows=106185 loops=1) + Group Key: _s12.ws_bill_customer_sk + Batches: 21 Memory Usage: 8265kB Disk Usage: 48368kB + -> Hash Join (cost=11.86..617228.70 rows=13136102 width=36) (actual time=5.427..4307.594 rows=1432881 loops=1) + Hash Cond: (_s12.ws_sold_date_sk = _t8.d_date_sk) + -> CTE Scan on _s8 _s12 (cost=0.00..143957.28 rows=7197864 width=44) (actual time=0.276..3643.146 rows=7197566 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=5.086..5.086 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 _t8 (cost=0.00..7.30 rows=365 width=8) (actual time=2.527..5.047 rows=365 loops=1) +Planning Time: 0.501 ms +JIT: + Functions: 111 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.782 ms, Inlining 94.265 ms, Optimization 664.721 ms, Emission 504.663 ms, Total 1270.431 ms +Execution Time: 54662.136 ms",SUCCESS +31,32,TPCDS,Q12,"SELECT + i.i_item_id, + i.i_item_desc, + i.i_category, + i.i_class, + i.i_current_price, + SUM(ws.ws_ext_sales_price) AS itemrevenue, + SUM(ws.ws_ext_sales_price) * 100.0 + / SUM(SUM(ws.ws_ext_sales_price)) OVER (PARTITION BY i.i_class) + AS revenueratio +FROM tpcds.web_sales ws +JOIN tpcds.item i + ON ws.ws_item_sk = i.i_item_sk +JOIN tpcds.date_dim d + ON ws.ws_sold_date_sk = d.d_date_sk +WHERE + i.i_category IN ('Sports', 'Books', 'Home') + AND d.d_date BETWEEN DATE '1999-02-22' + AND (DATE '1999-02-22' + INTERVAL '30 days') +GROUP BY + i.i_item_id, + i.i_item_desc, + i.i_category, + i.i_class, + i.i_current_price +ORDER BY + i.i_category, + i.i_class, + i.i_item_id, + i.i_item_desc, + revenueratio +LIMIT 100;","selected_sales = web_sales.WHERE(MONOTONIC(DATETIME('1999-02-22'), sold_date.date, DATETIME('1999-02-22', '+30 days'))) +result = items.WHERE( + PRESENT(item_class) + & PRESENT(current_price) + & HAS(selected_sales) + & ISIN(LOWER(category),('sports', 'books', 'home')) +).PARTITION( + name='i_class', by=item_class +).items.WHERE(HAS(selected_sales)).CALCULATE( + i_item_id=_id, + i_item_desc=description, + i_category=category, + i_class=item_class, + i_current_price=current_price, + itemrevenue=SUM(selected_sales.ext_sales_price), + revenueratio=(100*SUM(selected_sales.ext_sales_price)) / RELSUM(SUM(selected_sales.ext_sales_price), per='i_class') +).TOP_K(100, by=(category, item_class, _id, description, revenueratio))","WITH _t3 AS ( + SELECT + d_date, + d_date_sk + FROM tpcds.date_dim + WHERE + d_date <= CAST('1999-03-24' AS DATE) AND d_date >= CAST('1999-02-22' AS DATE) +), _u_0 AS ( + SELECT + web_sales.ws_item_sk AS _u_1 + FROM tpcds.web_sales AS web_sales + JOIN _t3 AS _t3 + ON _t3.d_date_sk = web_sales.ws_sold_date_sk + GROUP BY + 1 +), _t0 AS ( + SELECT + MAX(item.i_category) AS anything_i_category, + MAX(item.i_class) AS anything_i_class, + MAX(item.i_current_price) AS anything_i_current_price, + MAX(item.i_item_desc) AS anything_i_item_desc, + MAX(item.i_item_id) AS anything_i_item_id, + SUM(web_sales.ws_ext_sales_price) AS sum_ws_ext_sales_price + FROM tpcds.item AS item + LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = item.i_item_sk + JOIN tpcds.web_sales AS web_sales + ON item.i_item_sk = web_sales.ws_item_sk + JOIN _t3 AS _t4 + ON _t4.d_date_sk = web_sales.ws_sold_date_sk + WHERE + LOWER(item.i_category) IN ('sports', 'books', 'home') + AND NOT _u_0._u_1 IS NULL + AND NOT item.i_class IS NULL + AND NOT item.i_current_price IS NULL + GROUP BY + web_sales.ws_item_sk +) +SELECT + anything_i_item_id AS i_item_id, + anything_i_item_desc AS i_item_desc, + anything_i_category AS i_category, + anything_i_class AS i_class, + anything_i_current_price AS i_current_price, + COALESCE(sum_ws_ext_sales_price, 0) AS itemrevenue, + CAST(( + 100 * COALESCE(sum_ws_ext_sales_price, 0) + ) AS DOUBLE PRECISION) / SUM(COALESCE(sum_ws_ext_sales_price, 0)) OVER (PARTITION BY anything_i_class) AS revenueratio +FROM _t0 +ORDER BY + 3 NULLS FIRST, + 4 NULLS FIRST, + 1 NULLS FIRST, + 2 NULLS FIRST, + 7 NULLS FIRST +LIMIT 100",4.820676266999726,2.9522780819997934,"Limit (cost=307338.54..307338.79 rows=100 width=203) (actual time=1044.686..1045.714 rows=100 loops=1) + -> Sort (cost=307338.54..307340.75 rows=881 width=203) (actual time=1027.374..1028.395 rows=100 loops=1) + Sort Key: i.i_category, i.i_class, i.i_item_id, i.i_item_desc, ((((sum(ws.ws_ext_sales_price)) * 100.0) / sum((sum(ws.ws_ext_sales_price))) OVER (?))) + Sort Method: top-N heapsort Memory: 70kB + -> WindowAgg (cost=307285.05..307304.87 rows=881 width=203) (actual time=1016.558..1025.028 rows=11201 loops=1) + -> Sort (cost=307285.05..307287.25 rows=881 width=171) (actual time=1016.452..1018.002 rows=11201 loops=1) + Sort Key: i.i_class + Sort Method: quicksort Memory: 2307kB + -> Finalize GroupAggregate (cost=307122.37..307241.96 rows=881 width=171) (actual time=992.034..1012.375 rows=11201 loops=1) + Group Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + -> Gather Merge (cost=307122.37..307218.10 rows=734 width=171) (actual time=992.024..1004.219 rows=11201 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=306122.34..306133.35 rows=367 width=171) (actual time=971.428..975.718 rows=3734 loops=3) + Group Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + -> Sort (cost=306122.34..306123.26 rows=367 width=145) (actual time=971.402..971.769 rows=6829 loops=3) + Sort Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + Sort Method: quicksort Memory: 1275kB + Worker 0: Sort Method: quicksort Memory: 1851kB + Worker 1: Sort Method: quicksort Memory: 1144kB + -> Parallel Hash Join (cost=300969.32..306106.71 rows=367 width=145) (actual time=935.780..950.234 rows=6829 loops=3) + Hash Cond: (i.i_item_sk = ws.ws_item_sk) + -> Parallel Seq Scan on item i (cost=0.00..5088.38 rows=12664 width=147) (actual time=0.061..11.547 rows=10145 loops=3) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 23855 + -> Parallel Hash (cost=300953.93..300953.93 rows=1231 width=14) (actual time=935.495..935.497 rows=22946 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 5312kB + -> Parallel Hash Join (cost=2676.78..300953.93 rows=1231 width=14) (actual time=14.953..891.992 rows=22946 loops=3) + Hash Cond: (ws.ws_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on web_sales ws (cost=0.00..287023.10 rows=2999110 width=22) (actual time=0.197..661.483 rows=2399189 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=1.901..1.901 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=18 width=8) (actual time=2.817..5.689 rows=31 loops=1) + Filter: ((d_date >= '1999-02-22'::date) AND (d_date <= '1999-03-24 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 73018 +Planning Time: 0.211 ms +JIT: + Functions: 93 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 6.356 ms, Inlining 0.000 ms, Optimization 2.500 ms, Emission 50.582 ms, Total 59.438 ms +Execution Time: 1048.011 ms","Limit (cost=678780.78..678781.03 rows=100 width=200) (actual time=3279.967..3281.575 rows=100 loops=1) + CTE _t3 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=30 width=12) (actual time=2.380..4.634 rows=31 loops=1) + Filter: ((d_date <= '1999-03-24'::date) AND (d_date >= '1999-02-22'::date)) + Rows Removed by Filter: 73018 + -> Sort (cost=675653.05..675657.47 rows=1768 width=200) (actual time=2787.366..2788.956 rows=100 loops=1) + Sort Key: _t0.anything_i_category NULLS FIRST, _t0.anything_i_class NULLS FIRST, _t0.anything_i_item_id NULLS FIRST, _t0.anything_i_item_desc NULLS FIRST, (((('100'::numeric * COALESCE(_t0.sum_ws_ext_sales_price, '0'::numeric)))::double precision / (sum(COALESCE(_t0.sum_ws_ext_sales_price, '0'::numeric)) OVER (?))::double precision)) NULLS FIRST + Sort Method: top-N heapsort Memory: 67kB + -> WindowAgg (cost=675536.85..675585.47 rows=1768 width=200) (actual time=2775.726..2785.544 rows=11177 loops=1) + -> Sort (cost=675536.85..675541.27 rows=1768 width=192) (actual time=2775.629..2777.717 rows=11177 loops=1) + Sort Key: _t0.anything_i_class + Sort Method: quicksort Memory: 2298kB + -> Subquery Scan on _t0 (cost=675366.35..675441.49 rows=1768 width=192) (actual time=2754.311..2772.569 rows=11177 loops=1) + -> GroupAggregate (cost=675366.35..675423.81 rows=1768 width=200) (actual time=2754.305..2771.556 rows=11177 loops=1) + Group Key: web_sales.ws_item_sk + -> Sort (cost=675366.35..675370.77 rows=1768 width=153) (actual time=2754.260..2758.022 rows=20442 loops=1) + Sort Key: web_sales.ws_item_sk + Sort Method: external merge Disk: 3312kB + -> Hash Join (cost=365641.76..675270.98 rows=1768 width=153) (actual time=1628.098..2744.293 rows=20442 loops=1) + Hash Cond: (item.i_item_sk = web_sales_1.ws_item_sk) + -> Hash Join (cost=6203.54..315828.12 rows=1768 width=161) (actual time=333.839..1441.076 rows=20442 loops=1) + Hash Cond: (web_sales.ws_sold_date_sk = _t4.d_date_sk) + -> Gather (cost=6202.56..315406.44 rows=107474 width=169) (actual time=328.556..1123.761 rows=2141448 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5202.56..303659.04 rows=44781 width=169) (actual time=314.795..1117.260 rows=713816 loops=3) + Hash Cond: (web_sales.ws_item_sk = item.i_item_sk) + -> Parallel Seq Scan on web_sales (cost=0.00..287023.10 rows=2999110 width=22) (actual time=0.017..346.627 rows=2399189 loops=3) + -> Parallel Hash (cost=5194.62..5194.62 rows=635 width=147) (actual time=314.504..314.505 rows=10125 loops=3) + Buckets: 32768 (originally 2048) Batches: 1 (originally 1) Memory Usage: 6064kB + -> Parallel Seq Scan on item (cost=0.00..5194.62 rows=635 width=147) (actual time=190.475..210.733 rows=10125 loops=3) + Filter: ((i_class IS NOT NULL) AND (i_current_price IS NOT NULL) AND (lower((i_category)::text) = ANY ('{sports,books,home}'::text[]))) + Rows Removed by Filter: 23875 + -> Hash (cost=0.60..0.60 rows=30 width=8) (actual time=4.652..4.652 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 _t4 (cost=0.00..0.60 rows=30 width=8) (actual time=2.384..4.645 rows=31 loops=1) + -> Hash (cost=358352.51..358352.51 rows=86857 width=8) (actual time=1294.197..1294.200 rows=37612 loops=1) + Buckets: 131072 Batches: 1 Memory Usage: 2494kB + -> HashAggregate (cost=357483.94..358352.51 rows=86857 width=8) (actual time=1285.158..1289.759 rows=37612 loops=1) + Group Key: web_sales_1.ws_item_sk + Batches: 1 Memory Usage: 4625kB + -> Hash Join (cost=0.97..357187.88 rows=118427 width=8) (actual time=0.515..1269.572 rows=68837 loops=1) + Hash Cond: (web_sales_1.ws_sold_date_sk = _t3.d_date_sk) + -> Seq Scan on web_sales web_sales_1 (cost=0.00..329010.64 rows=7197864 width=16) (actual time=0.009..871.890 rows=7197566 loops=1) + Filter: (ws_item_sk IS NOT NULL) + -> Hash (cost=0.60..0.60 rows=30 width=8) (actual time=0.017..0.017 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 (cost=0.00..0.60 rows=30 width=8) (actual time=0.004..0.009 rows=31 loops=1) +Planning Time: 0.490 ms +JIT: + Functions: 91 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.602 ms, Inlining 115.481 ms, Optimization 574.273 ms, Emission 374.242 ms, Total 1069.599 ms +Execution Time: 3284.785 ms",SUCCESS +32,33,TPCDS,Q13,"select + avg(ss_quantity) as avg_ss_quantity, + avg(ss_ext_sales_price) as avg_ss_ext_sales_price, + avg(ss_ext_wholesale_cost) as avg_ss_ext_wholesale_cost, + sum(ss_ext_wholesale_cost) as sum_ss_ext_wholesale_cost +from + tpcds.store_sales, + tpcds.store, + tpcds.customer_demographics, + tpcds.household_demographics, + tpcds.customer_address, + tpcds.date_dim +where + s_store_sk = ss_store_sk + and ss_sold_date_sk = d_date_sk + and d_year = 2001 + and ss_cdemo_sk = cd_demo_sk + and cd_marital_status in ('M', 'S', 'W') + and cd_education_status in ( + 'Advanced Degree', + 'College', + '2 yr Degree' + ) + and ss_hdemo_sk = hd_demo_sk + and ss_addr_sk = ca_address_sk + and ca_state in ( + 'TX', 'OH', 'TX', + 'OR', 'NM', 'KY', + 'VA', 'TX', 'MS' + ) + and ss_net_profit between 100 and 200;","selected_store_sales = store_sales.WHERE( + (sold_date.year == 2001) + & HAS(store) + & HAS(customer_demographics) + & HAS(customer_address) + & HAS(household_demographics) + & ISIN(customer_demographics.marital_status, ('M', 'S', 'W')) + & ISIN(customer_demographics.education_status, ('Advanced Degree','College','2 yr Degree')) + & ISIN(customer_address.state, ('TX', 'OH', 'TX', 'OR', 'NM', 'KY', 'VA', 'TX', 'MS')) + & MONOTONIC(100, net_profit, 200) +) +result = TPCDS.CALCULATE( + avg_ss_quantity=AVG(selected_store_sales.quantity), + avg_ss_ext_sales_price=AVG(selected_store_sales.ext_sales_price), + avg_ss_ext_wholesale_cost=AVG(selected_store_sales.ext_wholesale_cost), + sum_ss_ext_wholesale_cost=SUM(selected_store_sales.ext_wholesale_cost) +)","SELECT + AVG(CAST(store_sales.ss_quantity AS DECIMAL)) AS avg_ss_quantity, + AVG(CAST(store_sales.ss_ext_sales_price AS DECIMAL)) AS avg_ss_ext_sales_price, + AVG(CAST(store_sales.ss_ext_wholesale_cost AS DECIMAL)) AS avg_ss_ext_wholesale_cost, + COALESCE(SUM(store_sales.ss_ext_wholesale_cost), 0) AS sum_ss_ext_wholesale_cost +FROM tpcds.store_sales AS store_sales +JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk AND date_dim.d_year = 2001 +JOIN tpcds.store AS store + ON store.s_store_sk = store_sales.ss_store_sk +JOIN tpcds.customer_demographics AS customer_demographics + ON customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk + AND customer_demographics.cd_education_status IN ('Advanced Degree', 'College', '2 yr Degree') + AND customer_demographics.cd_marital_status IN ('M', 'S', 'W') +JOIN tpcds.customer_address AS customer_address + ON customer_address.ca_address_sk = store_sales.ss_addr_sk + AND customer_address.ca_state IN ('TX', 'OH', 'TX', 'OR', 'NM', 'KY', 'VA', 'TX', 'MS') +JOIN tpcds.household_demographics AS household_demographics + ON household_demographics.hd_demo_sk = store_sales.ss_hdemo_sk +WHERE + store_sales.ss_net_profit <= 200 AND store_sales.ss_net_profit >= 100",14.037995961000888,14.437903025000196,"Finalize Aggregate (cost=906873.13..906873.14 rows=1 width=128) (actual time=14011.945..14022.016 rows=1 loops=1) + -> Gather (cost=906872.88..906873.09 rows=2 width=128) (actual time=14010.659..14021.994 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=905872.88..905872.89 rows=1 width=128) (actual time=13992.415..13992.684 rows=1 loops=3) + -> Hash Join (cost=899660.77..905871.73 rows=153 width=20) (actual time=13934.386..13991.991 rows=3246 loops=3) + Hash Cond: (store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk) + -> Hash Join (cost=899434.77..905643.60 rows=160 width=28) (actual time=13452.447..13509.077 rows=3249 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=899427.47..905634.07 rows=168 width=36) (actual time=13452.363..13508.316 rows=3259 loops=3) + Hash Cond: (customer_address.ca_address_sk = store_sales.ss_addr_sk) + -> Parallel Seq Scan on customer_address (cost=0.02..6050.52 rows=41441 width=8) (actual time=0.237..52.468 rows=19470 loops=3) + Filter: ((ca_state)::text = ANY ('{TX,OH,TX,OR,NM,KY,VA,TX,MS}'::text[])) + Rows Removed by Filter: 63863 + -> Parallel Hash (cost=899421.92..899421.92 rows=442 width=44) (actual time=13451.871..13452.137 rows=13988 loops=3) + Buckets: 65536 (originally 2048) Batches: 1 (originally 1) Memory Usage: 4304kB + -> Parallel Hash Join (cost=861574.25..899421.92 rows=442 width=44) (actual time=12997.223..13437.207 rows=13988 loops=3) + Hash Cond: (customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk) + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=204800 width=8) (actual time=0.271..408.405 rows=164640 loops=3) + Filter: (((cd_marital_status)::text = ANY ('{M,S,W}'::text[])) AND ((cd_education_status)::text = ANY ('{""Advanced Degree"",College,""2 yr Degree""}'::text[]))) + Rows Removed by Filter: 475627 + -> Parallel Hash (cost=861551.69..861551.69 rows=1805 width=52) (actual time=12996.790..12997.055 rows=55110 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 18112kB + -> Parallel Hash Join (cost=2571.81..861551.69 rows=1805 width=52) (actual time=7.403..12904.871 rows=55110 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..857549.82 rows=378512 width=60) (actual time=4.999..12851.918 rows=284169 loops=3) + Filter: ((ss_net_profit >= '100'::numeric) AND (ss_net_profit <= '200'::numeric)) + Rows Removed by Filter: 9316162 + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=2.308..2.309 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=3.504..6.846 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + -> Hash (cost=6.02..6.02 rows=102 width=8) (actual time=0.066..0.066 rows=102 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=8) (actual time=0.031..0.051 rows=102 loops=3) + -> Hash (cost=136.00..136.00 rows=7200 width=8) (actual time=481.787..481.787 rows=7200 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 346kB + -> Seq Scan on household_demographics (cost=0.00..136.00 rows=7200 width=8) (actual time=480.122..480.797 rows=7200 loops=3) +Planning Time: 0.451 ms +JIT: + Functions: 152 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.943 ms, Inlining 166.964 ms, Optimization 766.338 ms, Emission 507.371 ms, Total 1448.616 ms +Execution Time: 14024.239 ms","Finalize Aggregate (cost=906873.91..906873.92 rows=1 width=128) (actual time=13993.294..14003.802 rows=1 loops=1) + -> Gather (cost=906873.65..906873.86 rows=2 width=128) (actual time=13992.212..14003.773 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=905873.65..905873.66 rows=1 width=128) (actual time=13977.609..13978.011 rows=1 loops=3) + -> Hash Join (cost=899660.77..905871.73 rows=153 width=20) (actual time=13922.200..13976.960 rows=3246 loops=3) + Hash Cond: (store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk) + -> Hash Join (cost=899434.77..905643.60 rows=160 width=28) (actual time=13394.443..13448.136 rows=3249 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=899427.47..905634.07 rows=168 width=36) (actual time=13394.363..13447.374 rows=3259 loops=3) + Hash Cond: (customer_address.ca_address_sk = store_sales.ss_addr_sk) + -> Parallel Seq Scan on customer_address (cost=0.02..6050.52 rows=41441 width=8) (actual time=0.224..49.461 rows=19470 loops=3) + Filter: ((ca_state)::text = ANY ('{TX,OH,TX,OR,NM,KY,VA,TX,MS}'::text[])) + Rows Removed by Filter: 63863 + -> Parallel Hash (cost=899421.92..899421.92 rows=442 width=44) (actual time=13393.948..13394.346 rows=13988 loops=3) + Buckets: 65536 (originally 2048) Batches: 1 (originally 1) Memory Usage: 4304kB + -> Parallel Hash Join (cost=861574.25..899421.92 rows=442 width=44) (actual time=12941.378..13377.160 rows=13988 loops=3) + Hash Cond: (customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk) + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=204800 width=8) (actual time=0.406..405.557 rows=164640 loops=3) + Filter: (((cd_education_status)::text = ANY ('{""Advanced Degree"",College,""2 yr Degree""}'::text[])) AND ((cd_marital_status)::text = ANY ('{M,S,W}'::text[]))) + Rows Removed by Filter: 475627 + -> Parallel Hash (cost=861551.69..861551.69 rows=1805 width=52) (actual time=12940.840..12941.238 rows=55110 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 18112kB + -> Parallel Hash Join (cost=2571.81..861551.69 rows=1805 width=52) (actual time=5.148..12834.552 rows=55110 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..857549.82 rows=378512 width=60) (actual time=2.604..12782.113 rows=284169 loops=3) + Filter: ((ss_net_profit <= '200'::numeric) AND (ss_net_profit >= '100'::numeric)) + Rows Removed by Filter: 9316162 + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=2.339..2.340 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=3.812..6.966 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + -> Hash (cost=6.02..6.02 rows=102 width=8) (actual time=0.064..0.065 rows=102 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=8) (actual time=0.029..0.050 rows=102 loops=3) + -> Hash (cost=136.00..136.00 rows=7200 width=8) (actual time=527.613..527.614 rows=7200 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 346kB + -> Seq Scan on household_demographics (cost=0.00..136.00 rows=7200 width=8) (actual time=526.091..526.684 rows=7200 loops=3) +Planning Time: 0.426 ms +JIT: + Functions: 152 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.361 ms, Inlining 152.701 ms, Optimization 858.990 ms, Emission 566.878 ms, Total 1585.929 ms +Execution Time: 14006.082 ms",SUCCESS +33,34,TPCDS,Q15,"select + ca_zip, + sum(cs_sales_price) as total_catalog_sales +from + tpcds.catalog_sales, + tpcds.customer, + tpcds.customer_address, + tpcds.date_dim +where + cs_bill_customer_sk = c_customer_sk + and c_current_addr_sk = ca_address_sk + and ( + substr(ca_zip, 1, 5) in ( + '85669', '86197', '88274', '83405', '86475', + '85392', '85460', '80348', '81792' + ) + or ca_state in ('CA', 'WA', 'GA') + or cs_sales_price > 500 + ) + and cs_sold_date_sk = d_date_sk + and d_qoy = 2 + and d_year = 2001 +group by + ca_zip +order by + ca_zip +limit 100;","result = catalog_sales.CALCULATE( + ca_zip = bill_customer.current_address.zip_code[:5] +).WHERE( + PRESENT(ca_zip) + & HAS(bill_customer) + & ( + ISIN(ca_zip, ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792')) + | ISIN(bill_customer.current_address.state, ('CA', 'WA', 'GA')) + | (sales_price > 500) + ) + & (sold_date.quarter_of_year == 2) + & (sold_date.year == 2001) +).PARTITION( + name='zip_code', by=ca_zip +).CALCULATE( + ca_zip, + total_catalog_sales=SUM(catalog_sales.sales_price) +).TOP_K(100, by=ca_zip)","WITH _s3 AS ( + SELECT + customer.c_customer_sk, + customer_address.ca_state, + customer_address.ca_zip + FROM tpcds.customer AS customer + LEFT JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + WHERE + NOT SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) IS NULL +) +SELECT + SUBSTRING(_s3.ca_zip FROM 1 FOR 5) AS ca_zip, + COALESCE(SUM(catalog_sales.cs_sales_price), 0) AS total_catalog_sales +FROM tpcds.catalog_sales AS catalog_sales +JOIN _s3 AS _s3 + ON ( + SUBSTRING(_s3.ca_zip FROM 1 FOR 5) IN ('85669', '86197', '88274', '83405', '86475', '85392', '85460', '80348', '81792') + OR _s3.ca_state IN ('CA', 'WA', 'GA') + OR catalog_sales.cs_sales_price > 500 + ) + AND _s3.c_customer_sk = catalog_sales.cs_bill_customer_sk +JOIN tpcds.date_dim AS date_dim + ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk + AND date_dim.d_qoy = 2 + AND date_dim.d_year = 2001 +GROUP BY + 1 +ORDER BY + 1 NULLS FIRST +LIMIT 100",10.469409030999486,10.79016644999956,"Limit (cost=618968.64..618980.97 rows=100 width=38) (actual time=10413.535..10427.239 rows=100 loops=1) + -> Finalize GroupAggregate (cost=618968.64..619227.50 rows=2099 width=38) (actual time=10128.908..10142.602 rows=100 loops=1) + Group Key: customer_address.ca_zip + -> Gather Merge (cost=618968.64..619188.14 rows=1750 width=38) (actual time=10128.884..10142.400 rows=179 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=617968.62..617986.12 rows=875 width=38) (actual time=10112.000..10114.953 rows=239 loops=3) + Group Key: customer_address.ca_zip + -> Sort (cost=617968.62..617970.81 rows=875 width=12) (actual time=10111.962..10113.372 rows=7232 loops=3) + Sort Key: customer_address.ca_zip + Sort Method: quicksort Memory: 915kB + Worker 0: Sort Method: quicksort Memory: 752kB + Worker 1: Sort Method: quicksort Memory: 761kB + -> Parallel Hash Join (cost=611933.13..617925.86 rows=875 width=12) (actual time=10014.061..10106.446 rows=10919 loops=3) + Hash Cond: (customer_address.ca_address_sk = customer.c_current_addr_sk) + Join Filter: ((substr((customer_address.ca_zip)::text, 1, 5) = ANY ('{85669,86197,88274,83405,86475,85392,85460,80348,81792}'::text[])) OR ((customer_address.ca_state)::text = ANY ('{CA,WA,GA}'::text[])) OR (catalog_sales.cs_sales_price > '500'::numeric)) + Rows Removed by Join Filter: 126286 + -> Parallel Seq Scan on customer_address (cost=0.00..5529.67 rows=104167 width=17) (actual time=0.210..35.939 rows=83333 loops=3) + -> Parallel Hash (cost=611841.62..611841.62 rows=7319 width=14) (actual time=10013.129..10014.098 rows=137205 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27328kB + -> Parallel Hash Join (cost=597074.55..611841.62 rows=7319 width=14) (actual time=9792.592..9973.648 rows=137205 loops=3) + Hash Cond: (customer.c_customer_sk = catalog_sales.cs_bill_customer_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.198..140.920 rows=166667 loops=3) + -> Parallel Hash (cost=596982.61..596982.61 rows=7355 width=14) (actual time=9792.288..9793.255 rows=137555 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=2677.21..596982.61 rows=7355 width=14) (actual time=5990.687..9753.444 rows=137555 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=22) (actual time=0.189..9059.573 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=53 width=8) (actual time=2.639..2.640 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=53 width=8) (actual time=4.002..7.888 rows=91 loops=1) + Filter: ((d_qoy = 2) AND (d_year = 2001)) + Rows Removed by Filter: 72958 +Planning Time: 0.258 ms +JIT: + Functions: 118 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.883 ms, Inlining 158.303 ms, Optimization 585.809 ms, Emission 338.829 ms, Total 1088.824 ms +Execution Time: 10429.152 ms","Limit (cost=619228.62..619241.30 rows=100 width=64) (actual time=10457.541..10469.440 rows=100 loops=1) + -> Finalize GroupAggregate (cost=619228.62..619493.40 rows=2088 width=64) (actual time=10134.195..10146.087 rows=100 loops=1) + Group Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) + -> Gather Merge (cost=619228.62..619449.03 rows=1740 width=64) (actual time=10134.180..10145.993 rows=171 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=618228.60..618248.17 rows=870 width=64) (actual time=10117.181..10118.808 rows=211 loops=3) + Group Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) + -> Sort (cost=618228.60..618230.77 rows=870 width=38) (actual time=10117.140..10117.498 rows=6412 loops=3) + Sort Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) NULLS FIRST + Sort Method: quicksort Memory: 941kB + Worker 0: Sort Method: quicksort Memory: 739kB + Worker 1: Sort Method: quicksort Memory: 729kB + -> Parallel Hash Join (cost=611933.13..618186.12 rows=870 width=38) (actual time=10005.827..10110.692 rows=10718 loops=3) + Hash Cond: (customer_address.ca_address_sk = customer.c_current_addr_sk) + Join Filter: ((SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) = ANY ('{85669,86197,88274,83405,86475,85392,85460,80348,81792}'::text[])) OR ((customer_address.ca_state)::text = ANY ('{CA,WA,GA}'::text[])) OR (catalog_sales.cs_sales_price > '500'::numeric)) + Rows Removed by Join Filter: 122193 + -> Parallel Seq Scan on customer_address (cost=0.00..5790.08 rows=103646 width=17) (actual time=0.263..50.844 rows=80800 loops=3) + Filter: (SUBSTRING(ca_zip FROM 1 FOR 5) IS NOT NULL) + Rows Removed by Filter: 2533 + -> Parallel Hash (cost=611841.62..611841.62 rows=7319 width=14) (actual time=10004.715..10004.719 rows=137205 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=597074.55..611841.62 rows=7319 width=14) (actual time=9796.832..9961.881 rows=137205 loops=3) + Hash Cond: (customer.c_customer_sk = catalog_sales.cs_bill_customer_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.183..126.895 rows=166667 loops=3) + -> Parallel Hash (cost=596982.61..596982.61 rows=7355 width=14) (actual time=9796.538..9796.541 rows=137555 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=2677.21..596982.61 rows=7355 width=14) (actual time=6004.649..9747.248 rows=137555 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=22) (actual time=0.197..9010.415 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=53 width=8) (actual time=2.682..2.683 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=53 width=8) (actual time=4.097..8.019 rows=91 loops=1) + Filter: ((d_qoy = 2) AND (d_year = 2001)) + Rows Removed by Filter: 72958 +Planning Time: 0.315 ms +JIT: + Functions: 124 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.453 ms, Inlining 155.516 ms, Optimization 690.081 ms, Emission 385.586 ms, Total 1237.637 ms +Execution Time: 10471.489 ms",SUCCESS +34,35,TPCDS,Q18,"with cs_1998 as ( + select + cs.cs_item_sk, + cs.cs_bill_customer_sk, + cs.cs_bill_cdemo_sk, + cs.cs_quantity, + cs.cs_list_price, + cs.cs_coupon_amt, + cs.cs_sales_price, + cs.cs_net_profit + from tpcds.catalog_sales cs + join tpcds.date_dim d + on d.d_date_sk = cs.cs_sold_date_sk + where d.d_year = 1998 +), +bill_demo as ( + select + cd_demo_sk, + cd_dep_count + from tpcds.customer_demographics + where cd_gender = 'F' + and cd_education_status = 'Unknown' +), +cust_filtered as ( + select + c.c_customer_sk, + c.c_birth_year, + ca.ca_country, + ca.ca_state, + ca.ca_county + from tpcds.customer c + join tpcds.customer_demographics cd2 + on cd2.cd_demo_sk = c.c_current_cdemo_sk + join tpcds.customer_address ca + on ca.ca_address_sk = c.c_current_addr_sk + where c.c_birth_month in (1,2,6,8,9,12) + and ca.ca_state in ('MS','IN','ND','OK','NM','VA') +) +select + i.i_item_id, + cf.ca_country, + cf.ca_state, + cf.ca_county, + avg(cs.cs_quantity::decimal(12,2)) as agg1, + avg(cs.cs_list_price::decimal(12,2)) as agg2, + avg(cs.cs_coupon_amt::decimal(12,2)) as agg3, + avg(cs.cs_sales_price::decimal(12,2)) as agg4, + avg(cs.cs_net_profit::decimal(12,2)) as agg5, + avg(cf.c_birth_year::decimal(12,2)) as agg6, + avg(bd.cd_dep_count::decimal(12,2)) as agg7 +from cs_1998 cs +join bill_demo bd + on bd.cd_demo_sk = cs.cs_bill_cdemo_sk +join cust_filtered cf + on cf.c_customer_sk = cs.cs_bill_customer_sk +join tpcds.item i + on i.i_item_sk = cs.cs_item_sk +group by rollup ( + i.i_item_id, + cf.ca_country, + cf.ca_state, + cf.ca_county +) +order by + cf.ca_country, + cf.ca_state, + cf.ca_county, + i.i_item_id +limit 100;","result = catalog_sales.WHERE( + (sold_date.year == 1998) + & HAS(bill_customer.current_address) + & HAS(bill_customer_demographics) + & ISIN(bill_customer.birth_month, (1,2,6,8,9,12)) + & ISIN(bill_customer.current_address.state, ('MS','IN','ND','OK','NM','VA')) + & (bill_customer_demographics.gender == 'F') + & (bill_customer_demographics.education_status == 'Unknown') +).CALCULATE( + i_item_id=item._id, + ca_country=bill_customer.current_address.country, + ca_state=bill_customer.current_address.state, + ca_county=bill_customer.current_address.county, + birth_year=bill_customer.birth_year, + dep_count=bill_customer_demographics.dependent_count +).PARTITION( + name='item_location', by=(i_item_id, ca_country, ca_state, ca_county) +).CALCULATE( + i_item_id, + ca_country, + ca_state, + ca_county, + agg1=AVG(catalog_sales.quantity), + agg2=AVG(catalog_sales.list_price), + agg3=AVG(catalog_sales.coupon_amount), + agg4=AVG(catalog_sales.sales_price), + agg5=AVG(catalog_sales.net_profit), + agg6=AVG(catalog_sales.birth_year), + agg7=AVG(catalog_sales.dep_count) +).TOP_K(100, by=(ca_country.ASC(na_pos='last'), ca_state.ASC(na_pos='last'), ca_county.ASC(na_pos='last'), i_item_id.ASC(na_pos='last')))","WITH _s8 AS ( + SELECT + customer_address.ca_country, + customer_address.ca_county, + customer_address.ca_state, + catalog_sales.cs_item_sk, + COUNT(customer.c_birth_year) AS count_c_birth_year, + COUNT(customer_demographics.cd_dep_count) AS count_cd_dep_count, + COUNT(catalog_sales.cs_coupon_amt) AS count_cs_coupon_amt, + COUNT(catalog_sales.cs_list_price) AS count_cs_list_price, + COUNT(catalog_sales.cs_net_profit) AS count_cs_net_profit, + COUNT(catalog_sales.cs_quantity) AS count_cs_quantity, + COUNT(catalog_sales.cs_sales_price) AS count_cs_sales_price, + SUM(customer.c_birth_year) AS sum_c_birth_year, + SUM(customer_demographics.cd_dep_count) AS sum_cd_dep_count, + SUM(catalog_sales.cs_coupon_amt) AS sum_cs_coupon_amt, + SUM(catalog_sales.cs_list_price) AS sum_cs_list_price, + SUM(catalog_sales.cs_net_profit) AS sum_cs_net_profit, + SUM(catalog_sales.cs_quantity) AS sum_cs_quantity, + SUM(catalog_sales.cs_sales_price) AS sum_cs_sales_price + FROM tpcds.catalog_sales AS catalog_sales + JOIN tpcds.date_dim AS date_dim + ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk AND date_dim.d_year = 1998 + JOIN tpcds.customer_demographics AS customer_demographics + ON catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk + AND customer_demographics.cd_education_status = 'Unknown' + AND customer_demographics.cd_gender = 'F' + JOIN tpcds.customer AS customer + ON catalog_sales.cs_bill_customer_sk = customer.c_customer_sk + AND customer.c_birth_month IN (1, 2, 6, 8, 9, 12) + JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + AND customer_address.ca_state IN ('MS', 'IN', 'ND', 'OK', 'NM', 'VA') + GROUP BY + 1, + 2, + 3, + 4 +) +SELECT + item.i_item_id, + _s8.ca_country, + _s8.ca_state, + _s8.ca_county, + CAST(SUM(_s8.sum_cs_quantity) AS DOUBLE PRECISION) / SUM(_s8.count_cs_quantity) AS agg1, + CAST(SUM(_s8.sum_cs_list_price) AS DOUBLE PRECISION) / SUM(_s8.count_cs_list_price) AS agg2, + CAST(SUM(_s8.sum_cs_coupon_amt) AS DOUBLE PRECISION) / SUM(_s8.count_cs_coupon_amt) AS agg3, + CAST(SUM(_s8.sum_cs_sales_price) AS DOUBLE PRECISION) / SUM(_s8.count_cs_sales_price) AS agg4, + CAST(SUM(_s8.sum_cs_net_profit) AS DOUBLE PRECISION) / SUM(_s8.count_cs_net_profit) AS agg5, + CAST(SUM(_s8.sum_c_birth_year) AS DOUBLE PRECISION) / SUM(_s8.count_c_birth_year) AS agg6, + CAST(SUM(_s8.sum_cd_dep_count) AS DOUBLE PRECISION) / SUM(_s8.count_cd_dep_count) AS agg7 +FROM _s8 AS _s8 +JOIN tpcds.item AS item + ON _s8.cs_item_sk = item.i_item_sk +GROUP BY + 1, + 2, + 3, + 4 +ORDER BY + 2, + 3, + 4, + 1 +LIMIT 100",13.618632130000151,13.692958495999846,"Limit (cost=695311.78..695312.03 rows=100 width=272) (actual time=13359.109..13394.195 rows=100 loops=1) + -> Sort (cost=695311.78..695315.26 rows=1393 width=272) (actual time=12661.776..12696.855 rows=100 loops=1) + Sort Key: ca.ca_country, ca.ca_state, ca.ca_county, i.i_item_id + Sort Method: top-N heapsort Memory: 46kB + -> GroupAggregate (cost=695164.91..695258.54 rows=1393 width=272) (actual time=12528.984..12681.064 rows=52755 loops=1) + Group Key: i.i_item_id, ca.ca_country, ca.ca_state, ca.ca_county + Group Key: i.i_item_id, ca.ca_country, ca.ca_state + Group Key: i.i_item_id, ca.ca_country + Group Key: i.i_item_id + Group Key: () + -> Gather Merge (cost=695164.91..695205.44 rows=348 width=93) (actual time=12528.947..12573.098 rows=14238 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=694164.89..694165.25 rows=145 width=93) (actual time=12507.712..12507.989 rows=4746 loops=3) + Sort Key: i.i_item_id, ca.ca_country, ca.ca_state, ca.ca_county + Sort Method: quicksort Memory: 909kB + Worker 0: Sort Method: quicksort Memory: 714kB + Worker 1: Sort Method: quicksort Memory: 705kB + -> Parallel Hash Join (cost=689070.71..694159.69 rows=145 width=93) (actual time=12476.209..12491.550 rows=4746 loops=3) + Hash Cond: (i.i_item_sk = cs.cs_item_sk) + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=0.011..8.944 rows=34000 loops=3) + -> Parallel Hash (cost=689068.90..689068.90 rows=145 width=84) (actual time=12475.918..12475.928 rows=4746 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2040kB + -> Parallel Hash Join (cost=654991.72..689068.90 rows=145 width=84) (actual time=12037.667..12462.248 rows=4746 loops=3) + Hash Cond: (cd2.cd_demo_sk = c.c_current_cdemo_sk) + -> Parallel Seq Scan on customer_demographics cd2 (cost=0.00..31075.33 rows=800333 width=8) (actual time=0.154..362.619 rows=640267 loops=3) + -> Parallel Hash (cost=654989.84..654989.84 rows=150 width=92) (actual time=12036.576..12036.584 rows=4802 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2168kB + -> Parallel Hash Join (cost=648620.39..654989.84 rows=150 width=92) (actual time=11972.652..12028.676 rows=4802 loops=3) + Hash Cond: (ca.ca_address_sk = c.c_current_addr_sk) + -> Parallel Seq Scan on customer_address ca (cost=0.00..6310.92 rows=15441 width=39) (actual time=0.249..53.595 rows=12282 loops=3) + Filter: ((ca_state)::text = ANY ('{MS,IN,ND,OK,NM,VA}'::text[])) + Rows Removed by Filter: 71052 + -> Parallel Hash (cost=648607.72..648607.72 rows=1014 width=69) (actual time=11972.333..11972.340 rows=32138 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 12032kB + -> Parallel Hash Join (cost=632707.17..648607.72 rows=1014 width=69) (actual time=11760.775..11962.282 rows=32138 loops=3) + Hash Cond: (c.c_customer_sk = cs.cs_bill_customer_sk) + -> Parallel Seq Scan on customer c (cost=0.00..15517.83 rows=100930 width=32) (actual time=0.221..186.275 rows=79880 loops=3) + Filter: (c_birth_month = ANY ('{1,2,6,8,9,12}'::bigint[])) + Rows Removed by Filter: 86787 + -> Parallel Hash (cost=632680.89..632680.89 rows=2103 width=53) (actual time=11760.477..11760.483 rows=67467 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 21824kB + -> Parallel Hash Join (cost=597382.48..632680.89 rows=2103 width=53) (actual time=11521.427..11700.858 rows=67467 loops=3) + Hash Cond: (customer_demographics.cd_demo_sk = cs.cs_bill_cdemo_sk) + -> Parallel Seq Scan on customer_demographics (cost=0.00..35077.00 rows=56707 width=16) (actual time=0.224..436.051 rows=45733 loops=3) + Filter: (((cd_gender)::text = 'F'::text) AND ((cd_education_status)::text = 'Unknown'::text)) + Rows Removed by Filter: 594533 + -> Parallel Hash (cost=597009.60..597009.60 rows=29830 width=53) (actual time=11063.245..11063.248 rows=950367 loops=3) + Buckets: 131072 (originally 131072) Batches: 32 (originally 1) Memory Usage: 9024kB + -> Parallel Hash Join (cost=2571.81..597009.60 rows=29830 width=53) (actual time=471.127..10452.580 rows=950367 loops=3) + Hash Cond: (cs.cs_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on catalog_sales cs (cost=0.00..571759.33 rows=6000733 width=61) (actual time=0.220..9395.154 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=1.783..1.784 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=215 width=8) (actual time=2.665..5.294 rows=365 loops=1) + Filter: (d_year = 1998) + Rows Removed by Filter: 72684 +Planning Time: 1.146 ms +JIT: + Functions: 193 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 12.778 ms, Inlining 163.885 ms, Optimization 1185.203 ms, Emission 756.022 ms, Total 2117.888 ms +Execution Time: 13397.811 ms","Limit (cost=666459.57..666474.07 rows=100 width=104) (actual time=13436.828..13505.374 rows=100 loops=1) + -> GroupAggregate (cost=666459.57..666511.91 rows=361 width=104) (actual time=12672.083..12740.622 rows=100 loops=1) + Group Key: _s8.ca_country, _s8.ca_state, _s8.ca_county, item.i_item_id + -> Sort (cost=666459.57..666460.47 rows=361 width=328) (actual time=12672.046..12740.256 rows=101 loops=1) + Sort Key: _s8.ca_country, _s8.ca_state, _s8.ca_county, item.i_item_id + Sort Method: quicksort Memory: 2985kB + -> Hash Join (cost=656071.62..666444.23 rows=361 width=328) (actual time=12602.249..12700.681 rows=14405 loops=1) + Hash Cond: (item.i_item_sk = _s8.cs_item_sk) + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=25) (actual time=0.011..13.680 rows=102000 loops=1) + -> Hash (cost=656067.11..656067.11 rows=361 width=319) (actual time=12602.211..12670.415 rows=14405 loops=1) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2720kB + -> Subquery Scan on _s8 (cost=655995.29..656067.11 rows=361 width=319) (actual time=12570.164..12665.742 rows=14405 loops=1) + -> GroupAggregate (cost=655995.29..656063.50 rows=361 width=319) (actual time=12570.160..12664.371 rows=14405 loops=1) + Group Key: customer_address.ca_country, customer_address.ca_county, customer_address.ca_state, catalog_sales.cs_item_sk + -> Gather Merge (cost=655995.29..656037.33 rows=361 width=84) (actual time=12570.125..12643.179 rows=14405 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=654995.26..654995.64 rows=150 width=84) (actual time=12550.632..12550.882 rows=4802 loops=3) + Sort Key: customer_address.ca_country, customer_address.ca_county, customer_address.ca_state, catalog_sales.cs_item_sk + Sort Method: quicksort Memory: 568kB + Worker 0: Sort Method: quicksort Memory: 935kB + Worker 1: Sort Method: quicksort Memory: 701kB + -> Parallel Hash Join (cost=648620.39..654989.84 rows=150 width=84) (actual time=12467.522..12541.049 rows=4802 loops=3) + Hash Cond: (customer_address.ca_address_sk = customer.c_current_addr_sk) + -> Parallel Seq Scan on customer_address (cost=0.00..6310.92 rows=15441 width=39) (actual time=0.234..71.221 rows=12282 loops=3) + Filter: ((ca_state)::text = ANY ('{MS,IN,ND,OK,NM,VA}'::text[])) + Rows Removed by Filter: 71052 + -> Parallel Hash (cost=648607.72..648607.72 rows=1014 width=61) (actual time=12466.989..12466.996 rows=32138 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 11840kB + -> Parallel Hash Join (cost=632707.17..648607.72 rows=1014 width=61) (actual time=12278.489..12455.604 rows=32138 loops=3) + Hash Cond: (customer.c_customer_sk = catalog_sales.cs_bill_customer_sk) + -> Parallel Seq Scan on customer (cost=0.00..15517.83 rows=100930 width=24) (actual time=0.223..161.950 rows=79880 loops=3) + Filter: (c_birth_month = ANY ('{1,2,6,8,9,12}'::bigint[])) + Rows Removed by Filter: 86787 + -> Parallel Hash (cost=632680.89..632680.89 rows=2103 width=53) (actual time=12278.188..12278.194 rows=67467 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 23008kB + -> Parallel Hash Join (cost=597382.48..632680.89 rows=2103 width=53) (actual time=11969.046..12239.337 rows=67467 loops=3) + Hash Cond: (customer_demographics.cd_demo_sk = catalog_sales.cs_bill_cdemo_sk) + -> Parallel Seq Scan on customer_demographics (cost=0.00..35077.00 rows=56707 width=16) (actual time=0.225..431.192 rows=45733 loops=3) + Filter: (((cd_education_status)::text = 'Unknown'::text) AND ((cd_gender)::text = 'F'::text)) + Rows Removed by Filter: 594533 + -> Parallel Hash (cost=597009.60..597009.60 rows=29830 width=53) (actual time=11513.946..11513.949 rows=950367 loops=3) + Buckets: 65536 (originally 131072) Batches: 64 (originally 1) Memory Usage: 4864kB + -> Parallel Hash Join (cost=2571.81..597009.60 rows=29830 width=53) (actual time=371.340..10804.856 rows=950367 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=61) (actual time=0.209..9848.319 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=1.774..1.775 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=2.665..5.269 rows=365 loops=1) + Filter: (d_year = 1998) + Rows Removed by Filter: 72684 +Planning Time: 0.551 ms +JIT: + Functions: 154 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 11.005 ms, Inlining 168.388 ms, Optimization 1029.854 ms, Emission 674.921 ms, Total 1884.168 ms +Execution Time: 13509.483 ms",SUCCESS +35,36,TPCDS,Q19,"select + i.i_brand_id as brand_id, + i.i_brand as brand, + i.i_manufact_id, + i.i_manufact, + sum(ss.ss_ext_sales_price) as ext_price +from tpcds.date_dim d +join tpcds.store_sales ss + on d.d_date_sk = ss.ss_sold_date_sk +join tpcds.item i + on ss.ss_item_sk = i.i_item_sk +join tpcds.customer c + on ss.ss_customer_sk = c.c_customer_sk +join tpcds.customer_address ca + on c.c_current_addr_sk = ca.ca_address_sk +join tpcds.store s + on ss.ss_store_sk = s.s_store_sk +where i.i_manager_id = 8 + and d.d_moy = 11 + and d.d_year = 1998 + and substr(ca.ca_zip, 1, 5) <> substr(s.s_zip, 1, 5) +group by + i.i_brand, + i.i_brand_id, + i.i_manufact_id, + i.i_manufact +order by + ext_price desc, + i.i_brand, + i.i_brand_id, + i.i_manufact_id, + i.i_manufact +limit 100;","result = store_sales.WHERE( + HAS(customer) + & HAS(customer.current_address) + & HAS(store) + & (item.manager_id == 8) + & (sold_date.month_of_year == 11) + & (sold_date.year == 1998) + & (customer.current_address.zip_code[:5] != store.zip_code[:5]) +).CALCULATE( + brand_id=item.brand_id, + brand=item.brand, + i_manufact_id=item.manufacturer_id, + i_manufact=item.manufacturer +).PARTITION( + name='brand_manufacture', by=(brand, brand_id, i_manufact_id, i_manufact) +).CALCULATE( + brand_id, + brand, + i_manufact_id, + i_manufact, + ext_price=SUM(store_sales.ext_sales_price) +).TOP_K(100, by=(ext_price.DESC(), brand, brand_id, i_manufact_id, i_manufact))","SELECT + item.i_brand_id AS brand_id, + item.i_brand AS brand, + item.i_manufact_id, + item.i_manufact, + COALESCE(SUM(store_sales.ss_ext_sales_price), 0) AS ext_price +FROM tpcds.store_sales AS store_sales +JOIN tpcds.customer AS customer + ON customer.c_customer_sk = store_sales.ss_customer_sk +JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk +JOIN tpcds.store AS store + ON SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) <> SUBSTRING(store.s_zip FROM 1 FOR 5) + AND store.s_store_sk = store_sales.ss_store_sk +JOIN tpcds.item AS item + ON item.i_item_sk = store_sales.ss_item_sk AND item.i_manager_id = 8 +JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk + AND date_dim.d_moy = 11 + AND date_dim.d_year = 1998 +GROUP BY + 1, + 2, + 3, + 4 +ORDER BY + 5 DESC NULLS LAST, + 2 NULLS FIRST, + 1 NULLS FIRST, + 3 NULLS FIRST, + 4 NULLS FIRST +LIMIT 100",14.321918279000784,14.146070523999697,"Limit (cost=872472.65..872472.90 rows=100 width=77) (actual time=14114.047..14115.033 rows=100 loops=1) + -> Sort (cost=872472.65..872473.12 rows=188 width=77) (actual time=13645.307..13646.266 rows=100 loops=1) + Sort Key: (sum(ss.ss_ext_sales_price)) DESC, i.i_brand, i.i_brand_id, i.i_manufact_id, i.i_manufact + Sort Method: top-N heapsort Memory: 47kB + -> GroupAggregate (cost=871977.11..872465.55 rows=188 width=77) (actual time=13512.982..13645.829 rows=936 loops=1) + Group Key: i.i_brand, i.i_brand_id, i.i_manufact_id, i.i_manufact + -> Nested Loop (cost=871977.11..872460.85 rows=188 width=51) (actual time=13512.784..13643.371 rows=15051 loops=1) + Join Filter: ((ss.ss_store_sk = s.s_store_sk) AND (substr((ca.ca_zip)::text, 1, 5) <> substr((s.s_zip)::text, 1, 5))) + Rows Removed by Join Filter: 1593183 + -> Gather Merge (cost=871977.11..872000.16 rows=198 width=65) (actual time=13512.700..13517.715 rows=15767 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=870977.08..870977.29 rows=82 width=65) (actual time=13496.770..13497.069 rows=5256 loops=3) + Sort Key: i.i_brand, i.i_brand_id, i.i_manufact_id, i.i_manufact + Sort Method: quicksort Memory: 669kB + Worker 0: Sort Method: quicksort Memory: 764kB + Worker 1: Sort Method: quicksort Memory: 668kB + -> Parallel Hash Join (cost=865053.84..870974.48 rows=82 width=65) (actual time=13424.990..13486.069 rows=5256 loops=3) + Hash Cond: (ca.ca_address_sk = c.c_current_addr_sk) + -> Parallel Seq Scan on customer_address ca (cost=0.00..5529.67 rows=104167 width=14) (actual time=0.226..49.454 rows=83333 loops=3) + -> Parallel Hash (cost=865052.82..865052.82 rows=82 width=67) (actual time=13424.538..13424.543 rows=5256 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1944kB + -> Parallel Hash Join (cost=850315.90..865052.82 rows=82 width=67) (actual time=13251.714..13416.954 rows=5256 loops=3) + Hash Cond: (c.c_customer_sk = ss.ss_customer_sk) + -> Parallel Seq Scan on customer c (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.198..143.412 rows=166667 loops=3) + -> Parallel Hash (cost=850314.82..850314.82 rows=86 width=67) (actual time=13251.256..13251.260 rows=5387 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1976kB + -> Parallel Hash Join (cost=7722.08..850314.82 rows=86 width=67) (actual time=426.166..12880.965 rows=5387 loops=3) + Hash Cond: (ss.ss_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2676.76..845252.10 rows=4547 width=30) (actual time=3.999..12420.519 rows=294196 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=38) (actual time=0.231..11547.613 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=17 width=8) (actual time=3.328..3.329 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=17 width=8) (actual time=2.251..3.282 rows=10 loops=3) + Filter: ((d_moy = 11) AND (d_year = 1998)) + Rows Removed by Filter: 24340 + -> Parallel Hash (cost=5035.25..5035.25 rows=805 width=53) (actual time=421.899..421.900 rows=612 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 272kB + -> Parallel Seq Scan on item i (cost=0.00..5035.25 rows=805 width=53) (actual time=275.528..284.478 rows=612 loops=3) + Filter: (i_manager_id = 8) + Rows Removed by Filter: 33388 + -> Materialize (cost=0.00..6.53 rows=102 width=14) (actual time=0.000..0.004 rows=102 loops=15767) + -> Seq Scan on store s (cost=0.00..6.02 rows=102 width=14) (actual time=0.018..0.054 rows=102 loops=1) +Planning Time: 0.700 ms +JIT: + Functions: 129 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.332 ms, Inlining 102.818 ms, Optimization 723.518 ms, Emission 469.197 ms, Total 1302.865 ms +Execution Time: 14117.601 ms","Limit (cost=872472.65..872472.90 rows=100 width=77) (actual time=14092.150..14093.137 rows=100 loops=1) + -> Sort (cost=872472.65..872473.12 rows=188 width=77) (actual time=13629.828..13630.808 rows=100 loops=1) + Sort Key: (COALESCE(sum(store_sales.ss_ext_sales_price), '0'::numeric)) DESC NULLS LAST, item.i_brand NULLS FIRST, item.i_brand_id NULLS FIRST, item.i_manufact_id NULLS FIRST, item.i_manufact NULLS FIRST + Sort Method: top-N heapsort Memory: 47kB + -> GroupAggregate (cost=871977.11..872465.55 rows=188 width=77) (actual time=13493.540..13630.329 rows=936 loops=1) + Group Key: item.i_brand_id, item.i_brand, item.i_manufact_id, item.i_manufact + -> Nested Loop (cost=871977.11..872460.85 rows=188 width=51) (actual time=13493.406..13627.752 rows=15051 loops=1) + Join Filter: ((store_sales.ss_store_sk = store.s_store_sk) AND (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5) <> SUBSTRING(store.s_zip FROM 1 FOR 5))) + Rows Removed by Join Filter: 1593183 + -> Gather Merge (cost=871977.11..872000.16 rows=198 width=65) (actual time=13493.364..13498.251 rows=15767 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=870977.08..870977.29 rows=82 width=65) (actual time=13477.867..13478.179 rows=5256 loops=3) + Sort Key: item.i_brand_id NULLS FIRST, item.i_brand NULLS FIRST, item.i_manufact_id NULLS FIRST, item.i_manufact NULLS FIRST + Sort Method: quicksort Memory: 663kB + Worker 0: Sort Method: quicksort Memory: 643kB + Worker 1: Sort Method: quicksort Memory: 807kB + -> Parallel Hash Join (cost=865053.84..870974.48 rows=82 width=65) (actual time=13424.534..13473.054 rows=5256 loops=3) + Hash Cond: (customer_address.ca_address_sk = customer.c_current_addr_sk) + -> Parallel Seq Scan on customer_address (cost=0.00..5529.67 rows=104167 width=14) (actual time=0.187..37.188 rows=83333 loops=3) + -> Parallel Hash (cost=865052.82..865052.82 rows=82 width=67) (actual time=13424.108..13424.113 rows=5256 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1976kB + -> Parallel Hash Join (cost=850315.90..865052.82 rows=82 width=67) (actual time=13224.031..13417.504 rows=5256 loops=3) + Hash Cond: (customer.c_customer_sk = store_sales.ss_customer_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=16) (actual time=0.203..171.470 rows=166667 loops=3) + -> Parallel Hash (cost=850314.82..850314.82 rows=86 width=67) (actual time=13223.598..13223.603 rows=5387 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1976kB + -> Parallel Hash Join (cost=7722.08..850314.82 rows=86 width=67) (actual time=411.045..12861.405 rows=5387 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Hash Join (cost=2676.76..845252.10 rows=4547 width=30) (actual time=4.080..12416.359 rows=294196 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=38) (actual time=0.239..11556.060 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=17 width=8) (actual time=3.366..3.367 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=17 width=8) (actual time=2.244..3.296 rows=10 loops=3) + Filter: ((d_moy = 11) AND (d_year = 1998)) + Rows Removed by Filter: 24340 + -> Parallel Hash (cost=5035.25..5035.25 rows=805 width=53) (actual time=406.681..406.682 rows=612 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 208kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=805 width=53) (actual time=266.255..275.165 rows=612 loops=3) + Filter: (i_manager_id = 8) + Rows Removed by Filter: 33388 + -> Materialize (cost=0.00..6.53 rows=102 width=14) (actual time=0.000..0.004 rows=102 loops=15767) + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=14) (actual time=0.019..0.050 rows=102 loops=1) +Planning Time: 0.700 ms +JIT: + Functions: 129 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.268 ms, Inlining 100.054 ms, Optimization 707.806 ms, Emission 453.358 ms, Total 1268.486 ms +Execution Time: 14095.770 ms",SUCCESS +36,37,TPCDS,Q20,"select + i.i_item_id, + i.i_item_desc, + i.i_category, + i.i_class, + i.i_current_price, + sum(cs.cs_ext_sales_price) as itemrevenue, + sum(cs.cs_ext_sales_price) * 100 + / sum(sum(cs.cs_ext_sales_price)) over (partition by i.i_class) + as revenueratio +from tpcds.catalog_sales cs +join tpcds.item i + on cs.cs_item_sk = i.i_item_sk +join tpcds.date_dim d + on cs.cs_sold_date_sk = d.d_date_sk +where i.i_category in ('Sports','Books','Home') + and d.d_date between date '1999-02-22' + and date '1999-02-22' + interval '30 days' +group by + i.i_item_id, + i.i_item_desc, + i.i_category, + i.i_class, + i.i_current_price +order by + i.i_category, + i.i_class, + i.i_item_id, + i.i_item_desc, + revenueratio +limit 100;","selected_catalog_sales = catalog_sales.WHERE( + MONOTONIC(DATETIME('1999-02-22'), sold_date.date, DATETIME('1999-02-22', '+30 days')) +) +result = items.WHERE( + HAS(selected_catalog_sales) + & ISIN(category, ('Sports','Books','Home')) +).PARTITION( + name='i_class', by=item_class +).items.CALCULATE( + i_item_id=_id, + i_item_desc=description, + i_category=category, + i_class=item_class, + i_current_price=current_price, + itemrevenue=SUM(selected_catalog_sales.ext_sales_price), + revenueratio=(100*SUM(selected_catalog_sales.ext_sales_price)) / RELSUM(SUM(selected_catalog_sales.ext_sales_price), per='i_class') +).PARTITION( + name='items_desc', by=(i_item_id, i_item_desc, i_category, i_class, i_current_price, itemrevenue, revenueratio) +).TOP_K(100, by=(i_category, i_class.ASC(na_pos='last'), i_item_id, i_item_desc.ASC(na_pos='last'), revenueratio))","WITH _t3 AS ( + SELECT + d_date, + d_date_sk + FROM tpcds.date_dim + WHERE + d_date <= CAST('1999-03-24' AS DATE) AND d_date >= CAST('1999-02-22' AS DATE) +), _u_0 AS ( + SELECT + catalog_sales.cs_item_sk AS _u_1 + FROM tpcds.catalog_sales AS catalog_sales + JOIN _t3 AS _t3 + ON _t3.d_date_sk = catalog_sales.cs_sold_date_sk + GROUP BY + 1 +), _s7 AS ( + SELECT + catalog_sales.cs_ext_sales_price, + catalog_sales.cs_item_sk + FROM tpcds.catalog_sales AS catalog_sales + JOIN _t3 AS _t4 + ON _t4.d_date_sk = catalog_sales.cs_sold_date_sk +), _t0 AS ( + SELECT + MAX(item.i_category) AS anything_i_category, + MAX(item.i_class) AS anything_i_class, + MAX(item.i_current_price) AS anything_i_current_price, + MAX(item.i_item_desc) AS anything_i_item_desc, + MAX(item.i_item_id) AS anything_i_item_id, + SUM(_s7.cs_ext_sales_price) AS sum_cs_ext_sales_price + FROM tpcds.item AS item + LEFT JOIN _u_0 AS _u_0 + ON _u_0._u_1 = item.i_item_sk + LEFT JOIN _s7 AS _s7 + ON _s7.cs_item_sk = item.i_item_sk + WHERE + NOT _u_0._u_1 IS NULL AND item.i_category IN ('Sports', 'Books', 'Home') + GROUP BY + item.i_item_sk +) +SELECT + anything_i_item_id AS i_item_id, + anything_i_item_desc AS i_item_desc, + anything_i_category AS i_category, + anything_i_class AS i_class, + anything_i_current_price AS i_current_price, + COALESCE(sum_cs_ext_sales_price, 0) AS itemrevenue, + CAST(( + 100 * COALESCE(sum_cs_ext_sales_price, 0) + ) AS DOUBLE PRECISION) / SUM(COALESCE(sum_cs_ext_sales_price, 0)) OVER (PARTITION BY anything_i_class) AS revenueratio +FROM _t0 +ORDER BY + 3 NULLS FIRST, + 4, + 1 NULLS FIRST, + 2, + 7 NULLS FIRST +LIMIT 100",9.995258388000366,20.141198733000238,"Limit (cost=603659.95..603660.20 rows=100 width=203) (actual time=9981.047..9983.358 rows=100 loops=1) + -> Sort (cost=603659.95..603664.33 rows=1753 width=203) (actual time=9645.903..9648.208 rows=100 loops=1) + Sort Key: i.i_category, i.i_class, i.i_item_id, i.i_item_desc, ((((sum(cs.cs_ext_sales_price)) * '100'::numeric) / sum((sum(cs.cs_ext_sales_price))) OVER (?))) + Sort Method: top-N heapsort Memory: 67kB + -> WindowAgg (cost=603553.51..603592.95 rows=1753 width=203) (actual time=9632.889..9644.062 rows=14107 loops=1) + -> Sort (cost=603553.51..603557.89 rows=1753 width=171) (actual time=9632.777..9635.736 rows=14107 loops=1) + Sort Key: i.i_class + Sort Method: quicksort Memory: 2811kB + -> Finalize GroupAggregate (cost=603221.18..603459.06 rows=1753 width=171) (actual time=9600.262..9629.245 rows=14107 loops=1) + Group Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + -> Gather Merge (cost=603221.18..603411.60 rows=1460 width=171) (actual time=9600.244..9619.426 rows=14107 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=602221.16..602243.06 rows=730 width=171) (actual time=9581.609..9587.578 rows=4702 loops=3) + Group Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + -> Sort (cost=602221.16..602222.98 rows=730 width=145) (actual time=9581.578..9582.219 rows=13570 loops=3) + Sort Key: i.i_item_id, i.i_item_desc, i.i_category, i.i_class, i.i_current_price + Sort Method: quicksort Memory: 3803kB + Worker 0: Sort Method: quicksort Memory: 2181kB + Worker 1: Sort Method: quicksort Memory: 2254kB + -> Parallel Hash Join (cost=596984.21..602186.44 rows=730 width=145) (actual time=9524.415..9542.147 rows=13570 loops=3) + Hash Cond: (i.i_item_sk = cs.cs_item_sk) + -> Parallel Seq Scan on item i (cost=0.00..5088.38 rows=12664 width=147) (actual time=0.050..14.522 rows=10145 loops=3) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 23855 + -> Parallel Hash (cost=596953.56..596953.56 rows=2452 width=14) (actual time=9524.141..9524.144 rows=45386 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 10496kB + -> Parallel Hash Join (cost=2676.78..596953.56 rows=2452 width=14) (actual time=9420.997..9508.189 rows=45386 loops=3) + Hash Cond: (cs.cs_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on catalog_sales cs (cost=0.00..571759.33 rows=6000733 width=22) (actual time=0.124..8843.487 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=1.676..1.677 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=18 width=8) (actual time=2.566..5.015 rows=31 loops=1) + Filter: ((d_date >= '1999-02-22'::date) AND (d_date <= '1999-03-24 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 73018 +Planning Time: 0.221 ms +JIT: + Functions: 93 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.118 ms, Inlining 153.997 ms, Optimization 570.627 ms, Emission 375.685 ms, Total 1106.426 ms +Execution Time: 9985.353 ms","Limit (cost=1455272.43..1455272.68 rows=100 width=200) (actual time=19950.756..19950.773 rows=100 loops=1) + CTE _t3 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=30 width=12) (actual time=2.231..4.405 rows=31 loops=1) + Filter: ((d_date <= '1999-03-24'::date) AND (d_date >= '1999-02-22'::date)) + Rows Removed by Filter: 73018 + -> Sort (cost=1452144.70..1452220.68 rows=30393 width=200) (actual time=19425.751..19425.760 rows=100 loops=1) + Sort Key: _t0.anything_i_category NULLS FIRST, _t0.anything_i_class, _t0.anything_i_item_id NULLS FIRST, _t0.anything_i_item_desc, (((('100'::numeric * COALESCE(_t0.sum_cs_ext_sales_price, '0'::numeric)))::double precision / (sum(COALESCE(_t0.sum_cs_ext_sales_price, '0'::numeric)) OVER (?))::double precision)) NULLS FIRST + Sort Method: top-N heapsort Memory: 65kB + -> WindowAgg (cost=1450147.29..1450983.10 rows=30393 width=200) (actual time=19411.250..19421.473 rows=14107 loops=1) + -> Sort (cost=1450147.29..1450223.27 rows=30393 width=192) (actual time=19411.146..19411.799 rows=14107 loops=1) + Sort Key: _t0.anything_i_class + Sort Method: quicksort Memory: 2804kB + -> Subquery Scan on _t0 (cost=1443252.95..1445077.31 rows=30393 width=192) (actual time=19382.449..19405.933 rows=14107 loops=1) + -> GroupAggregate (cost=1443252.95..1444773.38 rows=30393 width=200) (actual time=19382.447..19404.953 rows=14107 loops=1) + Group Key: item.i_item_sk + -> Sort (cost=1443252.95..1443395.51 rows=57026 width=153) (actual time=19382.413..19386.748 rows=40709 loops=1) + Sort Key: item.i_item_sk + Sort Method: external merge Disk: 6608kB + -> Hash Right Join (cost=720697.20..1434264.58 rows=57026 width=153) (actual time=19279.884..19366.863 rows=40709 loops=1) + Hash Cond: (catalog_sales.cs_item_sk = item.i_item_sk) + -> Hash Join (cost=0.97..712119.66 rows=234250 width=14) (actual time=9688.600..9760.506 rows=136158 loops=1) + Hash Cond: (catalog_sales.cs_sold_date_sk = _t4.d_date_sk) + -> Seq Scan on catalog_sales (cost=0.00..655769.59 rows=14401759 width=22) (actual time=0.004..8889.128 rows=14401261 loops=1) + -> Hash (cost=0.60..0.60 rows=30 width=8) (actual time=0.012..0.013 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 _t4 (cost=0.00..0.60 rows=30 width=8) (actual time=0.004..0.007 rows=31 loops=1) + -> Hash (cost=720385.84..720385.84 rows=24831 width=147) (actual time=9588.228..9588.231 rows=14107 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 2794kB + -> Hash Join (cost=718991.70..720385.84 rows=24831 width=147) (actual time=9573.086..9585.333 rows=14107 loops=1) + Hash Cond: (catalog_sales_1.cs_item_sk = item.i_item_sk) + -> HashAggregate (cost=712705.29..713538.62 rows=83333 width=8) (actual time=9543.351..9547.598 rows=47342 loops=1) + Group Key: catalog_sales_1.cs_item_sk + Batches: 1 Memory Usage: 5137kB + -> Hash Join (cost=0.97..712119.66 rows=234250 width=8) (actual time=9444.628..9524.478 rows=136158 loops=1) + Hash Cond: (catalog_sales_1.cs_sold_date_sk = _t3.d_date_sk) + -> Seq Scan on catalog_sales catalog_sales_1 (cost=0.00..655769.59 rows=14401759 width=16) (actual time=0.014..8577.653 rows=14401261 loops=1) + Filter: (cs_item_sk IS NOT NULL) + -> Hash (cost=0.60..0.60 rows=30 width=8) (actual time=4.420..4.421 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 (cost=0.00..0.60 rows=30 width=8) (actual time=2.235..4.414 rows=31 loops=1) + -> Hash (cost=5906.50..5906.50 rows=30393 width=147) (actual time=29.715..29.716 rows=30436 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 5754kB + -> Seq Scan on item (cost=0.00..5906.50 rows=30393 width=147) (actual time=0.023..24.014 rows=30436 loops=1) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 71564 +Planning Time: 0.417 ms +JIT: + Functions: 58 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.663 ms, Inlining 14.166 ms, Optimization 306.254 ms, Emission 204.714 ms, Total 527.795 ms +Execution Time: 19954.554 ms",SUCCESS +37,38,TPCDS,Q21,"select * from ( + select + w.w_warehouse_name, + i.i_item_id, + sum( + case + when d.d_date < date '2000-03-11' + then inv.inv_quantity_on_hand + else 0 + end + ) as inv_before, + sum( + case + when d.d_date >= date '2000-03-11' + then inv.inv_quantity_on_hand + else 0 + end + ) as inv_after + from tpcds.inventory inv + join tpcds.warehouse w + on inv.inv_warehouse_sk = w.w_warehouse_sk + join tpcds.item i + on inv.inv_item_sk = i.i_item_sk + join tpcds.date_dim d + on inv.inv_date_sk = d.d_date_sk + where i.i_current_price between 0.99 and 1.49 + and d.d_date between date '2000-03-11' - interval '30 days' + and date '2000-03-11' + interval '30 days' + group by + w.w_warehouse_name, + i.i_item_id +) x +where + case + when inv_before > 0 + then inv_after::numeric / inv_before + else null + end between 2.0/3.0 and 3.0/2.0 +order by + w_warehouse_name, + i_item_id +limit 100;","result = inventory.WHERE( + PRESENT(warehouse.name) + & HAS(item) + & MONOTONIC(0.99, item.current_price, 1.49) + & MONOTONIC(DATETIME('2000-03-11', '-30 days'), snapshot_date.date, DATETIME('2000-03-11', '+30 days')) +).CALCULATE( + w_warehouse_name=warehouse.name, + i_item_id=item._id, + inventory_date=snapshot_date.date +).PARTITION( + name='warehouse_groups', by=(w_warehouse_name, i_item_id) +).CALCULATE( + w_warehouse_name, + i_item_id, + inv_before=SUM(KEEP_IF(inventory.quantity_on_hand, inventory.inventory_date < DATETIME('2000-03-11'))), + inv_after=SUM(KEEP_IF(inventory.quantity_on_hand, inventory.inventory_date > DATETIME('2000-03-11'))) +).WHERE( + MONOTONIC(2/3, IFF(inv_before > 0, inv_after/inv_before, None), 3/2) +).TOP_K(100, by=(w_warehouse_name, i_item_id))","WITH _t1 AS ( + SELECT + item.i_item_id, + warehouse.w_warehouse_name, + SUM( + CASE + WHEN date_dim.d_date > CAST('2000-03-11' AS DATE) + THEN inventory.inv_quantity_on_hand + ELSE NULL + END + ) AS sum_expr, + SUM( + CASE + WHEN date_dim.d_date < CAST('2000-03-11' AS DATE) + THEN inventory.inv_quantity_on_hand + ELSE NULL + END + ) AS sum_expr_3 + FROM tpcds.inventory AS inventory + JOIN tpcds.warehouse AS warehouse + ON NOT warehouse.w_warehouse_name IS NULL + AND inventory.inv_warehouse_sk = warehouse.w_warehouse_sk + JOIN tpcds.item AS item + ON inventory.inv_item_sk = item.i_item_sk + AND item.i_current_price <= 1.49 + AND item.i_current_price >= 0.99 + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date <= CAST('2000-04-10' AS DATE) + AND date_dim.d_date >= CAST('2000-02-10' AS DATE) + AND date_dim.d_date_sk = inventory.inv_date_sk + GROUP BY + 1, + 2 +) +SELECT + w_warehouse_name, + i_item_id, + sum_expr_3 AS inv_before, + COALESCE(sum_expr, 0) AS inv_after +FROM _t1 +WHERE + CASE + WHEN ( + NOT sum_expr_3 IS NULL AND sum_expr_3 > 0 + ) + THEN CAST(COALESCE(sum_expr, 0) AS DOUBLE PRECISION) / COALESCE(sum_expr_3, 0) + ELSE NULL + END <= 1.5 + AND CASE + WHEN ( + NOT sum_expr_3 IS NULL AND sum_expr_3 > 0 + ) + THEN CAST(COALESCE(sum_expr, 0) AS DOUBLE PRECISION) / COALESCE(sum_expr_3, 0) + ELSE NULL + END >= 0.6666666666666666 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST +LIMIT 100",19.53044601199963,19.86378170199987,"Limit (cost=1747051.07..1747186.94 rows=100 width=151) (actual time=19504.470..19512.366 rows=100 loops=1) + -> Finalize GroupAggregate (cost=1747051.07..1748066.03 rows=747 width=151) (actual time=19258.746..19266.634 rows=100 loops=1) + Group Key: w.w_warehouse_name, i.i_item_id + Filter: ((CASE WHEN (sum(CASE WHEN (d.d_date < '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END) > 0) THEN ((sum(CASE WHEN (d.d_date >= '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END))::numeric / (sum(CASE WHEN (d.d_date < '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END))::numeric) ELSE NULL::numeric END >= 0.66666666666666666667) AND (CASE WHEN (sum(CASE WHEN (d.d_date < '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END) > 0) THEN ((sum(CASE WHEN (d.d_date >= '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END))::numeric / (sum(CASE WHEN (d.d_date < '2000-03-11'::date) THEN inv.inv_quantity_on_hand ELSE 0 END))::numeric) ELSE NULL::numeric END <= 1.5000000000000000)) + Rows Removed by Filter: 53 + -> Gather Merge (cost=1747051.07..1747774.71 rows=5602 width=151) (actual time=19258.713..19266.382 rows=460 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1746051.05..1746128.07 rows=2801 width=151) (actual time=19233.580..19234.548 rows=578 loops=3) + Group Key: w.w_warehouse_name, i.i_item_id + -> Sort (cost=1746051.05..1746058.05 rows=2801 width=143) (actual time=19233.547..19234.127 rows=1885 loops=3) + Sort Key: w.w_warehouse_name, i.i_item_id + Sort Method: external merge Disk: 4560kB + Worker 0: Sort Method: external merge Disk: 5032kB + Worker 1: Sort Method: external merge Disk: 4928kB + -> Hash Join (cost=7863.96..1745890.67 rows=2801 width=143) (actual time=7981.201..18821.757 rows=96780 loops=3) + Hash Cond: (inv.inv_warehouse_sk = w.w_warehouse_sk) + -> Parallel Hash Join (cost=7851.71..1745839.90 rows=2801 width=33) (actual time=7764.723..18587.737 rows=96780 loops=3) + Hash Cond: (inv.inv_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2676.99..1740485.52 rows=44797 width=24) (actual time=7753.366..18405.345 rows=1530000 loops=3) + Hash Cond: (inv.inv_date_sk = d.d_date_sk) + -> Parallel Seq Scan on inventory inv (cost=0.00..1529552.57 rows=55464057 width=28) (actual time=0.203..14613.661 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=35 width=12) (actual time=2.320..2.320 rows=20 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=35 width=12) (actual time=3.326..6.939 rows=61 loops=1) + Filter: ((d_date >= '2000-02-10 00:00:00'::timestamp without time zone) AND (d_date <= '2000-04-10 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 72988 + -> Parallel Hash (cost=5141.50..5141.50 rows=2658 width=25) (actual time=11.190..11.190 rows=2155 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 480kB + -> Parallel Seq Scan on item i (cost=0.00..5141.50 rows=2658 width=25) (actual time=0.019..31.832 rows=6464 loops=1) + Filter: ((i_current_price >= 0.99) AND (i_current_price <= 1.49)) + Rows Removed by Filter: 95536 + -> Hash (cost=11.00..11.00 rows=100 width=126) (actual time=216.443..216.444 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on warehouse w (cost=0.00..11.00 rows=100 width=126) (actual time=216.423..216.426 rows=10 loops=3) +Planning Time: 0.290 ms +JIT: + Functions: 113 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.848 ms, Inlining 154.929 ms, Optimization 437.229 ms, Emission 303.047 ms, Total 900.053 ms +Execution Time: 19514.723 ms","Limit (cost=1748102.05..1748102.30 rows=100 width=151) (actual time=19620.340..19627.843 rows=100 loops=1) + -> Sort (cost=1748102.05..1748103.92 rows=747 width=151) (actual time=19354.767..19362.260 rows=100 loops=1) + Sort Key: _t1.w_warehouse_name NULLS FIRST, _t1.i_item_id NULLS FIRST + Sort Method: top-N heapsort Memory: 38kB + -> Subquery Scan on _t1 (cost=1747051.07..1748073.50 rows=747 width=151) (actual time=19287.472..19358.378 rows=16926 loops=1) + -> Finalize GroupAggregate (cost=1747051.07..1748066.03 rows=747 width=151) (actual time=19287.469..19357.156 rows=16926 loops=1) + Group Key: item.i_item_id, warehouse.w_warehouse_name + Filter: ((CASE WHEN ((sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END) IS NOT NULL) AND (sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END) > 0)) THEN ((COALESCE(sum(CASE WHEN (date_dim.d_date > '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END), '0'::bigint))::double precision / (COALESCE(sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END), '0'::bigint))::double precision) ELSE NULL::double precision END <= '1.5'::double precision) AND (CASE WHEN ((sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END) IS NOT NULL) AND (sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END) > 0)) THEN ((COALESCE(sum(CASE WHEN (date_dim.d_date > '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END), '0'::bigint))::double precision / (COALESCE(sum(CASE WHEN (date_dim.d_date < '2000-03-11'::date) THEN inventory.inv_quantity_on_hand ELSE NULL::integer END), '0'::bigint))::double precision) ELSE NULL::double precision END >= '0.6666666666666666'::double precision)) + Rows Removed by Filter: 12108 + -> Gather Merge (cost=1747051.07..1747774.71 rows=5602 width=151) (actual time=19287.438..19342.896 rows=81934 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1746051.05..1746128.07 rows=2801 width=151) (actual time=19244.683..19287.428 rows=27311 loops=3) + Group Key: item.i_item_id, warehouse.w_warehouse_name + -> Sort (cost=1746051.05..1746058.05 rows=2801 width=143) (actual time=19244.652..19266.748 rows=87102 loops=3) + Sort Key: item.i_item_id, warehouse.w_warehouse_name + Sort Method: external merge Disk: 4168kB + Worker 0: Sort Method: external merge Disk: 3528kB + Worker 1: Sort Method: external merge Disk: 5752kB + -> Hash Join (cost=7863.96..1745890.67 rows=2801 width=143) (actual time=7954.160..18951.296 rows=87102 loops=3) + Hash Cond: (inventory.inv_warehouse_sk = warehouse.w_warehouse_sk) + -> Parallel Hash Join (cost=7851.71..1745839.90 rows=2801 width=33) (actual time=7727.316..18707.790 rows=96780 loops=3) + Hash Cond: (inventory.inv_item_sk = item.i_item_sk) + -> Parallel Hash Join (cost=2676.99..1740485.52 rows=44797 width=24) (actual time=7716.567..18525.362 rows=1530000 loops=3) + Hash Cond: (inventory.inv_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on inventory (cost=0.00..1529552.57 rows=55464057 width=28) (actual time=0.215..14679.793 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=35 width=12) (actual time=2.259..2.259 rows=20 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=35 width=12) (actual time=3.457..6.755 rows=61 loops=1) + Filter: ((d_date <= '2000-04-10'::date) AND (d_date >= '2000-02-10'::date)) + Rows Removed by Filter: 72988 + -> Parallel Hash (cost=5141.50..5141.50 rows=2658 width=25) (actual time=10.529..10.530 rows=2155 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 480kB + -> Parallel Seq Scan on item (cost=0.00..5141.50 rows=2658 width=25) (actual time=0.029..29.805 rows=6464 loops=1) + Filter: ((i_current_price <= 1.49) AND (i_current_price >= 0.99)) + Rows Removed by Filter: 95536 + -> Hash (cost=11.00..11.00 rows=100 width=126) (actual time=226.801..226.802 rows=9 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on warehouse (cost=0.00..11.00 rows=100 width=126) (actual time=226.788..226.791 rows=9 loops=3) + Filter: (w_warehouse_name IS NOT NULL) + Rows Removed by Filter: 1 +Planning Time: 0.393 ms +JIT: + Functions: 120 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.208 ms, Inlining 150.217 ms, Optimization 468.425 ms, Emission 327.483 ms, Total 951.334 ms +Execution Time: 19630.297 ms",SUCCESS +38,39,TPCDS,Q22,"SELECT + i.i_product_name, + i.i_brand, + i.i_class, + i.i_category, + AVG(inv.inv_quantity_on_hand) AS qoh +FROM tpcds.inventory inv +JOIN tpcds.date_dim d + ON inv.inv_date_sk = d.d_date_sk +JOIN tpcds.item i + ON inv.inv_item_sk = i.i_item_sk +WHERE d.d_month_seq BETWEEN 1190 AND 1190 + 11 +GROUP BY ( -- ROLLUP DELETED + i.i_product_name, + i.i_brand, + i.i_class, + i.i_category +) +ORDER BY + qoh, + i.i_product_name, + i.i_brand, + i.i_class, + i.i_category +LIMIT 100;","result = inventory.WHERE(MONOTONIC(1190, snapshot_date.month_seq, (1190 + 11))).CALCULATE( + i_product_name=item.product_name, + i_brand=item.brand, + i_class=item.item_class, + i_category=item.category +).PARTITION( + name='item', by=(i_product_name, i_brand, i_class, i_category) +).CALCULATE( + i_product_name, + i_brand, + i_class, + i_category, + qoh=AVG(inventory.quantity_on_hand) +).TOP_K(100, by=(qoh.ASC(), i_product_name, i_brand, i_class, i_category))","WITH _s2 AS ( + SELECT + inventory.inv_item_sk, + COUNT(inventory.inv_quantity_on_hand) AS count_inv_quantity_on_hand, + SUM(inventory.inv_quantity_on_hand) AS sum_inv_quantity_on_hand + FROM tpcds.inventory AS inventory + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = inventory.inv_date_sk + AND date_dim.d_month_seq <= 1201 + AND date_dim.d_month_seq >= 1190 + GROUP BY + 1 +) +SELECT + item.i_product_name, + item.i_brand, + item.i_class, + item.i_category, + CAST(SUM(_s2.sum_inv_quantity_on_hand) AS DOUBLE PRECISION) / SUM(_s2.count_inv_quantity_on_hand) AS qoh +FROM _s2 AS _s2 +JOIN tpcds.item AS item + ON _s2.inv_item_sk = item.i_item_sk +GROUP BY + 1, + 2, + 3, + 4 +ORDER BY + 5 NULLS FIRST, + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST, + 4 NULLS FIRST +LIMIT 100",78.93559118200028,22.05169408399979,"Limit (cost=1818724.67..1818724.92 rows=100 width=83) (actual time=79928.361..79988.302 rows=100 loops=1) + -> Sort (cost=1818724.67..1818979.04 rows=101748 width=83) (actual time=79681.101..79741.035 rows=100 loops=1) + Sort Key: (avg(inv.inv_quantity_on_hand)), i.i_product_name, i.i_brand, i.i_class, i.i_category + Sort Method: top-N heapsort Memory: 46kB + -> Finalize GroupAggregate (cost=1782607.97..1814835.94 rows=101748 width=83) (actual time=73723.510..79721.847 rows=67967 loops=1) + Group Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + -> Gather Merge (cost=1782607.97..1811020.39 rows=203496 width=83) (actual time=73723.407..79648.307 rows=203901 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1781607.94..1786531.87 rows=101748 width=83) (actual time=67365.165..72410.413 rows=67967 loops=3) + Group Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + -> Sort (cost=1781607.94..1782259.02 rows=260430 width=55) (actual time=67365.057..70608.686 rows=8840000 loops=3) + Sort Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + Sort Method: external merge Disk: 532736kB + Worker 0: Sort Method: external merge Disk: 783848kB + Worker 1: Sort Method: external merge Disk: 464840kB + -> Parallel Hash Join (cost=8139.33..1749277.57 rows=260430 width=55) (actual time=4540.989..22474.083 rows=8840000 loops=3) + Hash Cond: (inv.inv_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2679.08..1741755.59 rows=260430 width=12) (actual time=4239.181..20087.810 rows=8840000 loops=3) + Hash Cond: (inv.inv_date_sk = d.d_date_sk) + -> Parallel Seq Scan on inventory inv (cost=0.00..1529552.57 rows=55464057 width=20) (actual time=0.252..15559.338 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=202 width=8) (actual time=3.285..3.285 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=202 width=8) (actual time=1.641..3.193 rows=122 loops=3) + Filter: ((d_month_seq >= 1190) AND (d_month_seq <= 1201)) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=4929.00..4929.00 rows=42500 width=59) (actual time=301.135..301.136 rows=34000 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 10784kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=59) (actual time=189.682..201.763 rows=34000 loops=3) +Planning Time: 0.201 ms +JIT: + Functions: 79 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.608 ms, Inlining 146.111 ms, Optimization 411.459 ms, Emission 258.933 ms, Total 821.111 ms +Execution Time: 80039.895 ms","Limit (cost=1824528.52..1824528.77 rows=100 width=59) (actual time=24223.217..24223.492 rows=100 loops=1) + -> Sort (cost=1824528.52..1824739.01 rows=84196 width=59) (actual time=23948.504..23948.772 rows=100 loops=1) + Sort Key: (((sum(_s2.sum_inv_quantity_on_hand))::double precision / (sum(_s2.count_inv_quantity_on_hand))::double precision)) NULLS FIRST, item.i_product_name NULLS FIRST, item.i_brand NULLS FIRST, item.i_class NULLS FIRST, item.i_category NULLS FIRST + Sort Method: top-N heapsort Memory: 43kB + -> GroupAggregate (cost=1817942.76..1821310.60 rows=84196 width=59) (actual time=23865.348..23936.807 rows=67967 loops=1) + Group Key: item.i_product_name, item.i_brand, item.i_class, item.i_category + -> Sort (cost=1817942.76..1818153.25 rows=84196 width=67) (actual time=23865.306..23889.877 rows=68000 loops=1) + Sort Key: item.i_product_name NULLS FIRST, item.i_brand NULLS FIRST, item.i_class NULLS FIRST, item.i_category NULLS FIRST + Sort Method: external merge Disk: 5528kB + -> Hash Join (cost=1778528.99..1807600.42 rows=84196 width=67) (actual time=21997.178..23694.303 rows=68000 loops=1) + Hash Cond: (_s2.inv_item_sk = item.i_item_sk) + -> Subquery Scan on _s2 (cost=1770633.99..1796463.72 rows=84196 width=24) (actual time=21953.766..23619.871 rows=68000 loops=1) + -> Finalize GroupAggregate (cost=1770633.99..1795621.76 rows=84196 width=24) (actual time=21953.763..23614.958 rows=68000 loops=1) + Group Key: inventory.inv_item_sk + -> Gather Merge (cost=1770633.99..1793516.86 rows=168392 width=24) (actual time=21953.723..23593.394 rows=204000 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1769633.96..1773080.22 rows=84196 width=24) (actual time=21706.603..23342.444 rows=68000 loops=3) + Group Key: inventory.inv_item_sk + -> Sort (cost=1769633.96..1770285.04 rows=260430 width=12) (actual time=21706.537..22653.570 rows=8840000 loops=3) + Sort Key: inventory.inv_item_sk + Sort Method: external merge Disk: 246088kB + Worker 0: Sort Method: external merge Disk: 158672kB + Worker 1: Sort Method: external merge Disk: 161104kB + -> Parallel Hash Join (cost=2679.08..1741755.59 rows=260430 width=12) (actual time=3998.908..18560.610 rows=8840000 loops=3) + Hash Cond: (inventory.inv_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on inventory (cost=0.00..1529552.57 rows=55464057 width=20) (actual time=0.185..13968.064 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=202 width=8) (actual time=2.242..2.243 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=202 width=8) (actual time=3.211..6.612 rows=366 loops=1) + Filter: ((d_month_seq <= 1201) AND (d_month_seq >= 1190)) + Rows Removed by Filter: 72683 + -> Hash (cost=5524.00..5524.00 rows=102000 width=59) (actual time=43.267..43.267 rows=102000 loops=1) + Buckets: 131072 Batches: 2 Memory Usage: 5855kB + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=59) (actual time=0.019..23.394 rows=102000 loops=1) +Planning Time: 0.274 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.369 ms, Inlining 138.999 ms, Optimization 275.721 ms, Emission 183.880 ms, Total 601.968 ms +Execution Time: 24247.691 ms",SUCCESS +39,40,TPCDS,Q26,"SELECT + i.i_item_id, + AVG(cs.cs_quantity) AS agg1, + AVG(cs.cs_list_price) AS agg2, + AVG(cs.cs_coupon_amt) AS agg3, + AVG(cs.cs_sales_price) AS agg4 +FROM tpcds.catalog_sales cs +JOIN tpcds.date_dim d + ON cs.cs_sold_date_sk = d.d_date_sk +JOIN tpcds.item i + ON cs.cs_item_sk = i.i_item_sk +JOIN tpcds.customer_demographics cd + ON cs.cs_bill_cdemo_sk = cd.cd_demo_sk +JOIN tpcds.promotion p + ON cs.cs_promo_sk = p.p_promo_sk +WHERE d.d_year = 2000 -- YEAR.01 + AND cd.cd_gender = 'M' -- GEN.01 + AND cd.cd_marital_status = 'S' -- MS.01 + AND cd.cd_education_status = 'College' -- ES.01 + AND p.p_channel_email = 'N' + AND p.p_channel_event = 'N' +GROUP BY i.i_item_id +ORDER BY i.i_item_id +LIMIT 100;","result = catalog_sales.WHERE( + (sold_date.year == 2000) + & (bill_customer_demographics.gender == 'M') + & (bill_customer_demographics.marital_status == 'S') + & (bill_customer_demographics.education_status == 'College') + & (promotion.channel_email == 'N') + & (promotion.channel_event == 'N') +).CALCULATE(i_item_id=item._id).PARTITION( + name='item_id', by=i_item_id +).CALCULATE( + i_item_id, + agg1=AVG(catalog_sales.quantity), + agg2=AVG(catalog_sales.list_price), + agg3=AVG(catalog_sales.coupon_amount), + agg4=AVG(catalog_sales.sales_price) +).TOP_K(100, by=i_item_id)","WITH _s6 AS ( + SELECT + catalog_sales.cs_item_sk, + COUNT(catalog_sales.cs_coupon_amt) AS count_cs_coupon_amt, + COUNT(catalog_sales.cs_list_price) AS count_cs_list_price, + COUNT(catalog_sales.cs_quantity) AS count_cs_quantity, + COUNT(catalog_sales.cs_sales_price) AS count_cs_sales_price, + SUM(catalog_sales.cs_coupon_amt) AS sum_cs_coupon_amt, + SUM(catalog_sales.cs_list_price) AS sum_cs_list_price, + SUM(catalog_sales.cs_quantity) AS sum_cs_quantity, + SUM(catalog_sales.cs_sales_price) AS sum_cs_sales_price + FROM tpcds.catalog_sales AS catalog_sales + JOIN tpcds.date_dim AS date_dim + ON catalog_sales.cs_sold_date_sk = date_dim.d_date_sk AND date_dim.d_year = 2000 + JOIN tpcds.customer_demographics AS customer_demographics + ON catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk + AND customer_demographics.cd_education_status = 'College' + AND customer_demographics.cd_gender = 'M' + AND customer_demographics.cd_marital_status = 'S' + JOIN tpcds.promotion AS promotion + ON catalog_sales.cs_promo_sk = promotion.p_promo_sk + AND promotion.p_channel_email = 'N' + AND promotion.p_channel_event = 'N' + GROUP BY + 1 +) +SELECT + item.i_item_id, + CAST(_s6.sum_cs_quantity AS DOUBLE PRECISION) / _s6.count_cs_quantity AS agg1, + CAST(_s6.sum_cs_list_price AS DOUBLE PRECISION) / _s6.count_cs_list_price AS agg2, + CAST(_s6.sum_cs_coupon_amt AS DOUBLE PRECISION) / _s6.count_cs_coupon_amt AS agg3, + CAST(_s6.sum_cs_sales_price AS DOUBLE PRECISION) / _s6.count_cs_sales_price AS agg4 +FROM _s6 AS _s6 +JOIN tpcds.item AS item + ON _s6.cs_item_sk = item.i_item_sk +ORDER BY + 1 NULLS FIRST +LIMIT 100",10.990045663000274,10.653942116000508,"Limit (cost=50013.01..264656.25 rows=100 width=145) (actual time=9853.147..11530.092 rows=100 loops=1) + -> GroupAggregate (cost=50013.01..2162102.52 rows=984 width=145) (actual time=9829.067..11505.997 rows=100 loops=1) + Group Key: i.i_item_id + -> Nested Loop (cost=50013.01..2162070.54 rows=984 width=40) (actual time=9820.031..11505.650 rows=142 loops=1) + Join Filter: (cs.cs_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 18260120 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=162.227..168.638 rows=469 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=128.482..128.553 rows=861 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 2126kB + Worker 1: Sort Method: quicksort Memory: 2120kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=2.028..12.138 rows=34000 loops=3) + -> Materialize (cost=40816.76..635477.18 rows=984 width=31) (actual time=4.029..22.005 rows=38934 loops=469) + -> Gather (cost=40816.76..635472.26 rows=984 width=31) (actual time=1889.768..9645.254 rows=39015 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=39816.76..634373.85 rows=410 width=31) (actual time=1870.861..9630.459 rows=13005 loops=3) + Hash Cond: (cs.cs_promo_sk = p.p_promo_sk) + -> Parallel Hash Join (cost=39792.17..634343.58 rows=423 width=39) (actual time=1858.491..9614.660 rows=13324 loops=3) + Hash Cond: (cs.cs_bill_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..597009.60 rows=29830 width=47) (actual time=1514.862..9179.358 rows=955783 loops=3) + Hash Cond: (cs.cs_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on catalog_sales cs (cost=0.00..571759.33 rows=6000733 width=55) (actual time=0.133..8481.426 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=3.203..3.204 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=215 width=8) (actual time=1.635..3.142 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=342.628..342.628 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11402 width=8) (actual time=0.291..339.851 rows=9147 loops=3) + Filter: (((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text) AND ((cd_education_status)::text = 'College'::text)) + Rows Removed by Filter: 631120 + -> Hash (cost=18.50..18.50 rows=487 width=8) (actual time=12.217..12.217 rows=489 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 28kB + -> Seq Scan on promotion p (cost=0.00..18.50 rows=487 width=8) (actual time=11.950..12.131 rows=489 loops=3) + Filter: (((p_channel_email)::text = 'N'::text) AND ((p_channel_event)::text = 'N'::text)) + Rows Removed by Filter: 11 +Planning Time: 0.388 ms +JIT: + Functions: 104 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 6.372 ms, Inlining 0.000 ms, Optimization 2.965 ms, Emission 63.221 ms, Total 72.558 ms +Execution Time: 11532.848 ms","Limit (cost=641429.12..641429.37 rows=100 width=49) (actual time=10394.110..10394.796 rows=100 loops=1) + -> Sort (cost=641429.12..641431.58 rows=984 width=49) (actual time=10074.335..10075.014 rows=100 loops=1) + Sort Key: item.i_item_id NULLS FIRST + Sort Method: top-N heapsort Memory: 47kB + -> Hash Join (cost=635570.23..641391.52 rows=984 width=49) (actual time=10019.870..10064.944 rows=27461 loops=1) + Hash Cond: (item.i_item_sk = _s6.cs_item_sk) + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=25) (actual time=0.012..12.188 rows=102000 loops=1) + -> Hash (cost=635557.93..635557.93 rows=984 width=168) (actual time=10019.814..10020.488 rows=27461 loops=1) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 3046kB + -> Subquery Scan on _s6 (cost=635391.67..635557.93 rows=984 width=168) (actual time=9975.220..10014.419 rows=27461 loops=1) + -> GroupAggregate (cost=635391.67..635548.09 rows=984 width=168) (actual time=9975.217..10012.361 rows=27461 loops=1) + Group Key: catalog_sales.cs_item_sk + -> Gather Merge (cost=635391.67..635506.27 rows=984 width=31) (actual time=9975.169..9982.843 rows=39015 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=634391.65..634392.67 rows=410 width=31) (actual time=9960.468..9961.921 rows=13005 loops=3) + Sort Key: catalog_sales.cs_item_sk + Sort Method: quicksort Memory: 1253kB + Worker 0: Sort Method: quicksort Memory: 1169kB + Worker 1: Sort Method: quicksort Memory: 1167kB + -> Hash Join (cost=39816.76..634373.85 rows=410 width=31) (actual time=1908.331..9956.076 rows=13005 loops=3) + Hash Cond: (catalog_sales.cs_promo_sk = promotion.p_promo_sk) + -> Parallel Hash Join (cost=39792.17..634343.58 rows=423 width=39) (actual time=1694.392..9738.908 rows=13324 loops=3) + Hash Cond: (catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..597009.60 rows=29830 width=47) (actual time=1582.218..9532.879 rows=955783 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=55) (actual time=5.260..8970.994 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=2.727..2.728 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=2.102..3.997 rows=183 loops=2) + Filter: (d_year = 2000) + Rows Removed by Filter: 36342 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=111.435..111.436 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11402 width=8) (actual time=0.148..161.796 rows=13720 loops=2) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 946680 + -> Hash (cost=18.50..18.50 rows=487 width=8) (actual time=213.872..213.872 rows=489 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 28kB + -> Seq Scan on promotion (cost=0.00..18.50 rows=487 width=8) (actual time=213.717..213.816 rows=489 loops=3) + Filter: (((p_channel_email)::text = 'N'::text) AND ((p_channel_event)::text = 'N'::text)) + Rows Removed by Filter: 11 +Planning Time: 0.406 ms +JIT: + Functions: 104 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.651 ms, Inlining 154.205 ms, Optimization 491.862 ms, Emission 315.072 ms, Total 966.790 ms +Execution Time: 10397.079 ms",SUCCESS +40,41,TPCDS,Q27,"SELECT + i.i_item_id, + s.s_state, + GROUPING(s.s_state) AS g_state, + AVG(ss.ss_quantity) AS agg1, + AVG(ss.ss_list_price) AS agg2, + AVG(ss.ss_coupon_amt) AS agg3, + AVG(ss.ss_sales_price) AS agg4 +FROM tpcds.store_sales ss +JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk +JOIN tpcds.item i + ON ss.ss_item_sk = i.i_item_sk +JOIN tpcds.store s + ON ss.ss_store_sk = s.s_store_sk +JOIN tpcds.customer_demographics cd + ON ss.ss_cdemo_sk = cd.cd_demo_sk +WHERE d.d_year = 2002 + AND cd.cd_gender = 'M' + AND cd.cd_marital_status = 'S' + AND cd.cd_education_status = 'College' + AND s.s_state IN ( + 'TN','TN','TN','TN','TN','TN' + ) +GROUP BY (i.i_item_id, s.s_state) +ORDER BY i.i_item_id, + s.s_state +LIMIT 100;","result = store_sales.WHERE( + (sold_date.year == 2002) + & (customer_demographics.gender == 'M') + & (customer_demographics.marital_status == 'S') + & (customer_demographics.education_status == 'College') + & (store.state == 'TN') +).CALCULATE( + i_item_id=item._id, + s_state=store.state +).PARTITION( + name='item_state', by=(i_item_id, s_state) +).CALCULATE( + i_item_id, + s_state, + g_state=0, + agg1=AVG(store_sales.quantity), + agg2=AVG(store_sales.list_price), + agg3=AVG(store_sales.coupon_amount), + agg4=AVG(store_sales.sales_price) +).TOP_K(100, by=(i_item_id, s_state))","WITH _s6 AS ( + SELECT + store.s_state, + store_sales.ss_item_sk, + COUNT(store_sales.ss_coupon_amt) AS count_ss_coupon_amt, + COUNT(store_sales.ss_list_price) AS count_ss_list_price, + COUNT(store_sales.ss_quantity) AS count_ss_quantity, + COUNT(store_sales.ss_sales_price) AS count_ss_sales_price, + SUM(store_sales.ss_coupon_amt) AS sum_ss_coupon_amt, + SUM(store_sales.ss_list_price) AS sum_ss_list_price, + SUM(store_sales.ss_quantity) AS sum_ss_quantity, + SUM(store_sales.ss_sales_price) AS sum_ss_sales_price + FROM tpcds.store_sales AS store_sales + JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk AND date_dim.d_year = 2002 + JOIN tpcds.customer_demographics AS customer_demographics + ON customer_demographics.cd_demo_sk = store_sales.ss_cdemo_sk + AND customer_demographics.cd_education_status = 'College' + AND customer_demographics.cd_gender = 'M' + AND customer_demographics.cd_marital_status = 'S' + JOIN tpcds.store AS store + ON store.s_state = 'TN' AND store.s_store_sk = store_sales.ss_store_sk + GROUP BY + 1, + 2 +) +SELECT + item.i_item_id, + _s6.s_state, + 0 AS g_state, + CAST(SUM(_s6.sum_ss_quantity) AS DOUBLE PRECISION) / SUM(_s6.count_ss_quantity) AS agg1, + CAST(SUM(_s6.sum_ss_list_price) AS DOUBLE PRECISION) / SUM(_s6.count_ss_list_price) AS agg2, + CAST(SUM(_s6.sum_ss_coupon_amt) AS DOUBLE PRECISION) / SUM(_s6.count_ss_coupon_amt) AS agg3, + CAST(SUM(_s6.sum_ss_sales_price) AS DOUBLE PRECISION) / SUM(_s6.count_ss_sales_price) AS agg4 +FROM _s6 AS _s6 +JOIN tpcds.item AS item + ON _s6.ss_item_sk = item.i_item_sk +GROUP BY + 1, + 2 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST +LIMIT 100",14.413083495000137,14.47944011600066,"Limit (cost=52062.31..259327.59 rows=100 width=152) (actual time=13968.840..15004.853 rows=100 loops=1) + -> GroupAggregate (cost=52062.31..3320635.65 rows=1577 width=152) (actual time=13949.087..14985.092 rows=100 loops=1) + Group Key: i.i_item_id, s.s_state + -> Incremental Sort (cost=52062.31..3320576.51 rows=1577 width=43) (actual time=13949.050..14984.887 rows=126 loops=1) + Sort Key: i.i_item_id, s.s_state + Presorted Key: i.i_item_id + Full-sort Groups: 4 Sort Method: quicksort Average Memory: 27kB Peak Memory: 27kB + -> Nested Loop (cost=49988.42..3320505.55 rows=1577 width=43) (actual time=9653.239..14984.783 rows=129 loops=1) + Join Filter: (ss.ss_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 14778769 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=183.828..190.492 rows=591 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=113.675..113.749 rows=875 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 1709kB + Worker 1: Sort Method: quicksort Memory: 2538kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=1.687..15.067 rows=34000 loops=3) + -> Materialize (cost=40792.17..886623.66 rows=1577 width=34) (actual time=0.613..23.640 rows=25007 loops=591) + -> Nested Loop (cost=40792.17..886615.78 rows=1577 width=34) (actual time=362.302..13422.731 rows=25041 loops=1) + Join Filter: (ss.ss_store_sk = s.s_store_sk) + Rows Removed by Join Filter: 2327921 + -> Gather (cost=40792.17..884082.92 rows=1871 width=39) (actual time=362.226..13146.586 rows=75902 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=39792.17..882895.82 rows=780 width=39) (actual time=346.628..13312.818 rows=25301 loops=3) + Hash Cond: (ss.ss_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..845457.60 rows=57230 width=47) (actual time=4.099..12782.888 rows=1834706 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=55) (actual time=0.226..11451.022 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=3.635..3.636 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=215 width=8) (actual time=1.894..3.563 rows=122 loops=3) + Filter: (d_year = 2002) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=339.991..339.992 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11402 width=8) (actual time=8.788..337.131 rows=9147 loops=3) + Filter: (((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text) AND ((cd_education_status)::text = 'College'::text)) + Rows Removed by Filter: 631120 + -> Materialize (cost=0.00..7.24 rows=90 width=11) (actual time=0.000..0.002 rows=31 loops=75902) + -> Seq Scan on store s (cost=0.00..6.79 rows=90 width=11) (actual time=0.019..0.086 rows=31 loops=1) + Filter: ((s_state)::text = ANY ('{TN,TN,TN,TN,TN,TN}'::text[])) + Rows Removed by Filter: 71 +Planning Time: 0.399 ms +JIT: + Functions: 87 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 5.138 ms, Inlining 0.000 ms, Optimization 2.435 ms, Emission 48.242 ms, Total 55.816 ms +Execution Time: 15007.507 ms","Limit (cost=890839.41..890848.16 rows=100 width=56) (actual time=14044.487..14045.355 rows=100 loops=1) + -> GroupAggregate (cost=890839.41..890886.92 rows=543 width=56) (actual time=13619.970..13620.831 rows=100 loops=1) + Group Key: item.i_item_id, store.s_state + -> Sort (cost=890839.41..890840.76 rows=543 width=180) (actual time=13619.924..13620.577 rows=101 loops=1) + Sort Key: item.i_item_id NULLS FIRST, store.s_state NULLS FIRST + Sort Method: quicksort Memory: 2885kB + -> Hash Join (cost=890715.53..890814.74 rows=543 width=180) (actual time=13529.746..13559.716 rows=19773 loops=1) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> GroupAggregate (cost=883916.53..884002.84 rows=543 width=171) (actual time=13497.254..13520.778 rows=19773 loops=1) + Group Key: store_sales.ss_item_sk + -> Gather Merge (cost=883916.53..883979.77 rows=543 width=34) (actual time=13497.213..13501.876 rows=25041 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=882916.50..882917.07 rows=226 width=34) (actual time=13482.041..13482.886 rows=8347 loops=3) + Sort Key: store_sales.ss_item_sk + Sort Method: quicksort Memory: 947kB + Worker 0: Sort Method: quicksort Memory: 919kB + Worker 1: Sort Method: quicksort Memory: 692kB + -> Hash Join (cost=39798.83..882907.66 rows=226 width=34) (actual time=401.280..13479.123 rows=8347 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=39792.17..882895.82 rows=780 width=39) (actual time=101.306..13176.640 rows=25301 loops=3) + Hash Cond: (store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.81..845457.60 rows=57230 width=47) (actual time=2.532..12897.405 rows=1834706 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=55) (actual time=0.187..11745.087 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=2.202..2.203 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=215 width=8) (actual time=3.340..6.528 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 + -> Parallel Hash (cost=37077.83..37077.83 rows=11402 width=8) (actual time=97.117..97.118 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1344kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11402 width=8) (actual time=0.218..280.828 rows=27440 loops=1) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 1893360 + -> Hash (cost=6.28..6.28 rows=31 width=11) (actual time=298.574..298.575 rows=31 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> Seq Scan on store (cost=0.00..6.28 rows=31 width=11) (actual time=298.527..298.563 rows=31 loops=3) + Filter: ((s_state)::text = 'TN'::text) + Rows Removed by Filter: 71 + -> Hash (cost=5524.00..5524.00 rows=102000 width=25) (actual time=32.439..32.439 rows=102000 loops=1) + Buckets: 131072 Batches: 1 Memory Usage: 7399kB + -> Seq Scan on item (cost=0.00..5524.00 rows=102000 width=25) (actual time=0.018..20.195 rows=102000 loops=1) +Planning Time: 0.402 ms +JIT: + Functions: 110 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.638 ms, Inlining 185.360 ms, Optimization 716.018 ms, Emission 418.842 ms, Total 1326.859 ms +Execution Time: 14047.967 ms",SUCCESS +41,42,TPCDS,Q28,"SELECT * FROM +( + SELECT + AVG(ss_list_price) AS B1_LP, + COUNT(ss_list_price) AS B1_CNT, + COUNT(DISTINCT ss_list_price) AS B1_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 0 AND 5 + AND ( + ss_list_price BETWEEN 8 AND 8 + 10 + OR ss_coupon_amt BETWEEN 459 AND 459 + 1000 + OR ss_wholesale_cost BETWEEN 57 AND 57 + 20 + ) +) B1, +( + SELECT + AVG(ss_list_price) AS B2_LP, + COUNT(ss_list_price) AS B2_CNT, + COUNT(DISTINCT ss_list_price) AS B2_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 6 AND 10 + AND ( + ss_list_price BETWEEN 90 AND 90 + 10 + OR ss_coupon_amt BETWEEN 2323 AND 2323 + 1000 + OR ss_wholesale_cost BETWEEN 31 AND 31 + 20 + ) +) B2, +( + SELECT + AVG(ss_list_price) AS B3_LP, + COUNT(ss_list_price) AS B3_CNT, + COUNT(DISTINCT ss_list_price) AS B3_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 11 AND 15 + AND ( + ss_list_price BETWEEN 142 AND 142 + 10 + OR ss_coupon_amt BETWEEN 12214 AND 12214 + 1000 + OR ss_wholesale_cost BETWEEN 79 AND 79 + 20 + ) +) B3, +( + SELECT + AVG(ss_list_price) AS B4_LP, + COUNT(ss_list_price) AS B4_CNT, + COUNT(DISTINCT ss_list_price) AS B4_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 16 AND 20 + AND ( + ss_list_price BETWEEN 135 AND 135 + 10 + OR ss_coupon_amt BETWEEN 6071 AND 6071 + 1000 + OR ss_wholesale_cost BETWEEN 38 AND 38 + 20 + ) +) B4, +( + SELECT + AVG(ss_list_price) AS B5_LP, + COUNT(ss_list_price) AS B5_CNT, + COUNT(DISTINCT ss_list_price) AS B5_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 21 AND 25 + AND ( + ss_list_price BETWEEN 122 AND 122 + 10 + OR ss_coupon_amt BETWEEN 836 AND 836 + 1000 + OR ss_wholesale_cost BETWEEN 17 AND 17 + 20 + ) +) B5, +( + SELECT + AVG(ss_list_price) AS B6_LP, + COUNT(ss_list_price) AS B6_CNT, + COUNT(DISTINCT ss_list_price) AS B6_CNTD + FROM tpcds.store_sales + WHERE ss_quantity BETWEEN 26 AND 30 + AND ( + ss_list_price BETWEEN 154 AND 154 + 10 + OR ss_coupon_amt BETWEEN 7326 AND 7326 + 1000 + OR ss_wholesale_cost BETWEEN 7 AND 7 + 20 + ) +) B6 +LIMIT 100;","bucket1_sales = store_sales.WHERE( + MONOTONIC(0, quantity, 5) + & ( + MONOTONIC(8, list_price, (8+10)) + | MONOTONIC(459, coupon_amount, (459 + 1000)) + | MONOTONIC(57, wholesale_cost, (57 + 20)) + ) +) +bucket2_sales = store_sales.WHERE( + MONOTONIC(6, quantity, 10) + & ( + MONOTONIC(90, list_price, (90+10)) + | MONOTONIC(2323, coupon_amount, (2323 + 1000)) + | MONOTONIC(31, wholesale_cost, (31 + 20)) + ) +) +bucket3_sales = store_sales.WHERE( + MONOTONIC(11, quantity, 15) + & ( + MONOTONIC(142, list_price, (142+10)) + | MONOTONIC(12214, coupon_amount, (12214 + 1000)) + | MONOTONIC(79, wholesale_cost, (79 + 20)) + ) +) +bucket4_sales = store_sales.WHERE( + MONOTONIC(16, quantity, 20) + & ( + MONOTONIC(135, list_price, (135+10)) + | MONOTONIC(6071, coupon_amount, (6071 + 1000)) + | MONOTONIC(38, wholesale_cost, (38 + 20)) + ) +) +bucket5_sales = store_sales.WHERE( + MONOTONIC(21, quantity, 25) + & ( + MONOTONIC(122, list_price, (122+10)) + | MONOTONIC(836, coupon_amount, (836 + 1000)) + | MONOTONIC(17, wholesale_cost, (17 + 20)) + ) +) + +bucket6_sales = store_sales.WHERE( + MONOTONIC(26, quantity, 30) + & ( + MONOTONIC(154, list_price, (154+10)) + | MONOTONIC(7326, coupon_amount, (7326 + 1000)) + | MONOTONIC(7, wholesale_cost, (7 + 20)) + ) +) +result = TPCDS.CALCULATE( + b1_lp=AVG(bucket1_sales.list_price), + b1_cnt=COUNT(bucket1_sales.list_price), + b1_cntd=NDISTINCT(bucket1_sales.list_price), + + b2_lp=AVG(bucket2_sales.list_price), + b2_cnt=COUNT(bucket2_sales.list_price), + b2_cntd=NDISTINCT(bucket2_sales.list_price), + + b3_lp=AVG(bucket3_sales.list_price), + b3_cnt=COUNT(bucket3_sales.list_price), + b3_cntd=NDISTINCT(bucket3_sales.list_price), + + b4_lp=AVG(bucket4_sales.list_price), + b4_cnt=COUNT(bucket4_sales.list_price), + b4_cntd=NDISTINCT(bucket4_sales.list_price), + + b5_lp=AVG(bucket5_sales.list_price), + b5_cnt=COUNT(bucket5_sales.list_price), + b5_cntd=NDISTINCT(bucket5_sales.list_price), + + b6_lp=AVG(bucket6_sales.list_price), + b6_cnt=COUNT(bucket6_sales.list_price), + b6_cntd=NDISTINCT(bucket6_sales.list_price) +)","WITH _s0 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 1459 OR ss_list_price <= 18 OR ss_wholesale_cost <= 77 + ) + AND ( + ss_coupon_amt <= 1459 OR ss_list_price <= 18 OR ss_wholesale_cost >= 57 + ) + AND ( + ss_coupon_amt <= 1459 OR ss_list_price >= 8 OR ss_wholesale_cost <= 77 + ) + AND ( + ss_coupon_amt <= 1459 OR ss_list_price >= 8 OR ss_wholesale_cost >= 57 + ) + AND ( + ss_coupon_amt >= 459 OR ss_list_price <= 18 OR ss_wholesale_cost <= 77 + ) + AND ( + ss_coupon_amt >= 459 OR ss_list_price <= 18 OR ss_wholesale_cost >= 57 + ) + AND ( + ss_coupon_amt >= 459 OR ss_list_price >= 8 OR ss_wholesale_cost <= 77 + ) + AND ( + ss_coupon_amt >= 459 OR ss_list_price >= 8 OR ss_wholesale_cost >= 57 + ) + AND ss_quantity <= 5 + AND ss_quantity >= 0 +), _s1 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 3323 OR ss_list_price <= 100 OR ss_wholesale_cost <= 51 + ) + AND ( + ss_coupon_amt <= 3323 OR ss_list_price <= 100 OR ss_wholesale_cost >= 31 + ) + AND ( + ss_coupon_amt <= 3323 OR ss_list_price >= 90 OR ss_wholesale_cost <= 51 + ) + AND ( + ss_coupon_amt <= 3323 OR ss_list_price >= 90 OR ss_wholesale_cost >= 31 + ) + AND ( + ss_coupon_amt >= 2323 OR ss_list_price <= 100 OR ss_wholesale_cost <= 51 + ) + AND ( + ss_coupon_amt >= 2323 OR ss_list_price <= 100 OR ss_wholesale_cost >= 31 + ) + AND ( + ss_coupon_amt >= 2323 OR ss_list_price >= 90 OR ss_wholesale_cost <= 51 + ) + AND ( + ss_coupon_amt >= 2323 OR ss_list_price >= 90 OR ss_wholesale_cost >= 31 + ) + AND ss_quantity <= 10 + AND ss_quantity >= 6 +), _s3 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 13214 OR ss_list_price <= 152 OR ss_wholesale_cost <= 99 + ) + AND ( + ss_coupon_amt <= 13214 OR ss_list_price <= 152 OR ss_wholesale_cost >= 79 + ) + AND ( + ss_coupon_amt <= 13214 OR ss_list_price >= 142 OR ss_wholesale_cost <= 99 + ) + AND ( + ss_coupon_amt <= 13214 OR ss_list_price >= 142 OR ss_wholesale_cost >= 79 + ) + AND ( + ss_coupon_amt >= 12214 OR ss_list_price <= 152 OR ss_wholesale_cost <= 99 + ) + AND ( + ss_coupon_amt >= 12214 OR ss_list_price <= 152 OR ss_wholesale_cost >= 79 + ) + AND ( + ss_coupon_amt >= 12214 OR ss_list_price >= 142 OR ss_wholesale_cost <= 99 + ) + AND ( + ss_coupon_amt >= 12214 OR ss_list_price >= 142 OR ss_wholesale_cost >= 79 + ) + AND ss_quantity <= 15 + AND ss_quantity >= 11 +), _s5 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 7071 OR ss_list_price <= 145 OR ss_wholesale_cost <= 58 + ) + AND ( + ss_coupon_amt <= 7071 OR ss_list_price <= 145 OR ss_wholesale_cost >= 38 + ) + AND ( + ss_coupon_amt <= 7071 OR ss_list_price >= 135 OR ss_wholesale_cost <= 58 + ) + AND ( + ss_coupon_amt <= 7071 OR ss_list_price >= 135 OR ss_wholesale_cost >= 38 + ) + AND ( + ss_coupon_amt >= 6071 OR ss_list_price <= 145 OR ss_wholesale_cost <= 58 + ) + AND ( + ss_coupon_amt >= 6071 OR ss_list_price <= 145 OR ss_wholesale_cost >= 38 + ) + AND ( + ss_coupon_amt >= 6071 OR ss_list_price >= 135 OR ss_wholesale_cost <= 58 + ) + AND ( + ss_coupon_amt >= 6071 OR ss_list_price >= 135 OR ss_wholesale_cost >= 38 + ) + AND ss_quantity <= 20 + AND ss_quantity >= 16 +), _s7 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 1836 OR ss_list_price <= 132 OR ss_wholesale_cost <= 37 + ) + AND ( + ss_coupon_amt <= 1836 OR ss_list_price <= 132 OR ss_wholesale_cost >= 17 + ) + AND ( + ss_coupon_amt <= 1836 OR ss_list_price >= 122 OR ss_wholesale_cost <= 37 + ) + AND ( + ss_coupon_amt <= 1836 OR ss_list_price >= 122 OR ss_wholesale_cost >= 17 + ) + AND ( + ss_coupon_amt >= 836 OR ss_list_price <= 132 OR ss_wholesale_cost <= 37 + ) + AND ( + ss_coupon_amt >= 836 OR ss_list_price <= 132 OR ss_wholesale_cost >= 17 + ) + AND ( + ss_coupon_amt >= 836 OR ss_list_price >= 122 OR ss_wholesale_cost <= 37 + ) + AND ( + ss_coupon_amt >= 836 OR ss_list_price >= 122 OR ss_wholesale_cost >= 17 + ) + AND ss_quantity <= 25 + AND ss_quantity >= 21 +), _s9 AS ( + SELECT + AVG(CAST(ss_list_price AS DECIMAL)) AS avg_ss_list_price, + COUNT(ss_list_price) AS count_ss_list_price, + COUNT(DISTINCT ss_list_price) AS ndistinct_ss_list_price + FROM tpcds.store_sales + WHERE + ( + ss_coupon_amt <= 8326 OR ss_list_price <= 164 OR ss_wholesale_cost <= 27 + ) + AND ( + ss_coupon_amt <= 8326 OR ss_list_price <= 164 OR ss_wholesale_cost >= 7 + ) + AND ( + ss_coupon_amt <= 8326 OR ss_list_price >= 154 OR ss_wholesale_cost <= 27 + ) + AND ( + ss_coupon_amt <= 8326 OR ss_list_price >= 154 OR ss_wholesale_cost >= 7 + ) + AND ( + ss_coupon_amt >= 7326 OR ss_list_price <= 164 OR ss_wholesale_cost <= 27 + ) + AND ( + ss_coupon_amt >= 7326 OR ss_list_price <= 164 OR ss_wholesale_cost >= 7 + ) + AND ( + ss_coupon_amt >= 7326 OR ss_list_price >= 154 OR ss_wholesale_cost <= 27 + ) + AND ( + ss_coupon_amt >= 7326 OR ss_list_price >= 154 OR ss_wholesale_cost >= 7 + ) + AND ss_quantity <= 30 + AND ss_quantity >= 26 +) +SELECT + _s0.avg_ss_list_price AS b1_lp, + _s0.count_ss_list_price AS b1_cnt, + _s0.ndistinct_ss_list_price AS b1_cntd, + _s1.avg_ss_list_price AS b2_lp, + _s1.count_ss_list_price AS b2_cnt, + _s1.ndistinct_ss_list_price AS b2_cntd, + _s3.avg_ss_list_price AS b3_lp, + _s3.count_ss_list_price AS b3_cnt, + _s3.ndistinct_ss_list_price AS b3_cntd, + _s5.avg_ss_list_price AS b4_lp, + _s5.count_ss_list_price AS b4_cnt, + _s5.ndistinct_ss_list_price AS b4_cntd, + _s7.avg_ss_list_price AS b5_lp, + _s7.count_ss_list_price AS b5_cnt, + _s7.ndistinct_ss_list_price AS b5_cntd, + _s9.avg_ss_list_price AS b6_lp, + _s9.count_ss_list_price AS b6_cnt, + _s9.ndistinct_ss_list_price AS b6_cntd +FROM _s0 AS _s0 +CROSS JOIN _s1 AS _s1 +CROSS JOIN _s3 AS _s3 +CROSS JOIN _s5 AS _s5 +CROSS JOIN _s7 AS _s7 +CROSS JOIN _s9 AS _s9",80.10449133900056,80.91520609300005,"Limit (cost=6554717.28..6554717.39 rows=1 width=288) (actual time=80257.351..80265.534 rows=1 loops=1) + -> Nested Loop (cost=6554717.28..6554717.39 rows=1 width=288) (actual time=79662.696..79670.878 rows=1 loops=1) + -> Nested Loop (cost=5470560.42..5470560.51 rows=1 width=240) (actual time=66418.098..66418.460 rows=1 loops=1) + -> Nested Loop (cost=4376203.98..4376204.05 rows=1 width=192) (actual time=53059.796..53060.107 rows=1 loops=1) + -> Nested Loop (cost=3287980.99..3287981.04 rows=1 width=144) (actual time=39752.697..39752.950 rows=1 loops=1) + -> Nested Loop (cost=2199953.96..2199953.99 rows=1 width=96) (actual time=26449.482..26449.655 rows=1 loops=1) + -> Aggregate (cost=1102477.90..1102477.91 rows=1 width=48) (actual time=13120.077..13120.184 rows=1 loops=1) + -> Gather Merge (cost=1054659.57..1099584.88 rows=385736 width=6) (actual time=13008.267..13077.924 rows=367014 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1053659.54..1054061.35 rows=160723 width=6) (actual time=12994.331..13008.019 rows=122338 loops=3) + Sort Key: store_sales.ss_list_price + Sort Method: external merge Disk: 1352kB + Worker 0: Sort Method: external merge Disk: 1288kB + Worker 1: Sort Method: external merge Disk: 1304kB + -> Parallel Seq Scan on store_sales (cost=0.00..1037563.65 rows=160723 width=6) (actual time=133.950..12939.635 rows=122338 loops=3) + Filter: ((ss_quantity >= 0) AND (ss_quantity <= 5) AND (((ss_list_price >= '8'::numeric) AND (ss_list_price <= '18'::numeric)) OR ((ss_coupon_amt >= '459'::numeric) AND (ss_coupon_amt <= '1459'::numeric)) OR ((ss_wholesale_cost >= '57'::numeric) AND (ss_wholesale_cost <= '77'::numeric)))) + Rows Removed by Filter: 9477992 + -> Aggregate (cost=1097476.06..1097476.07 rows=1 width=48) (actual time=13329.399..13329.462 rows=1 loops=1) + -> Gather Merge (cost=1053336.68..1094805.62 rows=356059 width=6) (actual time=13217.551..13285.324 rows=355872 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1052336.66..1052707.55 rows=148358 width=6) (actual time=13192.739..13205.371 rows=118624 loops=3) + Sort Key: store_sales_1.ss_list_price + Sort Method: external sort Disk: 1864kB + Worker 0: Sort Method: external merge Disk: 1240kB + Worker 1: Sort Method: external merge Disk: 1216kB + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..1037563.65 rows=148358 width=6) (actual time=121.786..13140.125 rows=118624 loops=3) + Filter: ((ss_quantity >= 6) AND (ss_quantity <= 10) AND (((ss_list_price >= '90'::numeric) AND (ss_list_price <= '100'::numeric)) OR ((ss_coupon_amt >= '2323'::numeric) AND (ss_coupon_amt <= '3323'::numeric)) OR ((ss_wholesale_cost >= '31'::numeric) AND (ss_wholesale_cost <= '51'::numeric)))) + Rows Removed by Filter: 9481706 + -> Aggregate (cost=1088027.02..1088027.03 rows=1 width=48) (actual time=13303.209..13303.288 rows=1 loops=1) + -> Gather Merge (cost=1049545.35..1085698.87 rows=310420 width=6) (actual time=13215.473..13267.084 rows=282365 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1048545.32..1048868.68 rows=129342 width=6) (actual time=13193.826..13198.004 rows=94122 loops=3) + Sort Key: store_sales_2.ss_list_price + Sort Method: quicksort Memory: 4037kB + Worker 0: Sort Method: quicksort Memory: 3881kB + Worker 1: Sort Method: quicksort Memory: 3852kB + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..1037563.65 rows=129342 width=6) (actual time=124.745..13152.873 rows=94122 loops=3) + Filter: ((ss_quantity >= 11) AND (ss_quantity <= 15) AND (((ss_list_price >= '142'::numeric) AND (ss_list_price <= '152'::numeric)) OR ((ss_coupon_amt >= '12214'::numeric) AND (ss_coupon_amt <= '13214'::numeric)) OR ((ss_wholesale_cost >= '79'::numeric) AND (ss_wholesale_cost <= '99'::numeric)))) + Rows Removed by Filter: 9506209 + -> Aggregate (cost=1088222.99..1088223.00 rows=1 width=48) (actual time=13307.093..13307.149 rows=1 loops=1) + -> Gather Merge (cost=1049591.69..1085885.79 rows=311627 width=6) (actual time=13214.477..13270.741 rows=319172 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1048591.67..1048916.28 rows=129845 width=6) (actual time=13193.604..13199.237 rows=106391 loops=3) + Sort Key: store_sales_3.ss_list_price + Sort Method: external sort Disk: 1664kB + Worker 0: Sort Method: quicksort Memory: 4038kB + Worker 1: Sort Method: quicksort Memory: 4078kB + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..1037563.65 rows=129845 width=6) (actual time=142.499..13143.567 rows=106391 loops=3) + Filter: ((ss_quantity >= 16) AND (ss_quantity <= 20) AND (((ss_list_price >= '135'::numeric) AND (ss_list_price <= '145'::numeric)) OR ((ss_coupon_amt >= '6071'::numeric) AND (ss_coupon_amt <= '7071'::numeric)) OR ((ss_wholesale_cost >= '38'::numeric) AND (ss_wholesale_cost <= '58'::numeric)))) + Rows Removed by Filter: 9493940 + -> Aggregate (cost=1094356.44..1094356.45 rows=1 width=48) (actual time=13358.295..13358.345 rows=1 loops=1) + -> Gather Merge (cost=1052514.27..1091824.97 rows=337528 width=6) (actual time=13234.365..13309.926 rows=365262 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1051514.25..1051865.84 rows=140637 width=6) (actual time=13208.770..13222.762 rows=121754 loops=3) + Sort Key: store_sales_4.ss_list_price + Sort Method: external sort Disk: 1880kB + Worker 0: Sort Method: external merge Disk: 1296kB + Worker 1: Sort Method: external merge Disk: 1248kB + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..1037563.65 rows=140637 width=6) (actual time=136.137..13155.268 rows=121754 loops=3) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 25) AND (((ss_list_price >= '122'::numeric) AND (ss_list_price <= '132'::numeric)) OR ((ss_coupon_amt >= '836'::numeric) AND (ss_coupon_amt <= '1836'::numeric)) OR ((ss_wholesale_cost >= '17'::numeric) AND (ss_wholesale_cost <= '37'::numeric)))) + Rows Removed by Filter: 9478576 + -> Aggregate (cost=1084156.86..1084156.87 rows=1 width=48) (actual time=13244.588..13252.407 rows=1 loops=1) + -> Gather Merge (cost=1048632.53..1082007.63 rows=286564 width=6) (actual time=13150.275..13215.404 rows=302090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1047632.50..1047931.01 rows=119402 width=6) (actual time=13131.096..13136.855 rows=100697 loops=3) + Sort Key: store_sales_5.ss_list_price + Sort Method: external sort Disk: 1560kB + Worker 0: Sort Method: quicksort Memory: 3946kB + Worker 1: Sort Method: quicksort Memory: 4013kB + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..1037563.65 rows=119402 width=6) (actual time=123.601..13083.962 rows=100697 loops=3) + Filter: ((ss_quantity >= 26) AND (ss_quantity <= 30) AND (((ss_list_price >= '154'::numeric) AND (ss_list_price <= '164'::numeric)) OR ((ss_coupon_amt >= '7326'::numeric) AND (ss_coupon_amt <= '8326'::numeric)) OR ((ss_wholesale_cost >= '7'::numeric) AND (ss_wholesale_cost <= '27'::numeric)))) + Rows Removed by Filter: 9499634 +Planning Time: 0.510 ms +JIT: + Functions: 90 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 12.619 ms, Inlining 822.940 ms, Optimization 1324.441 ms, Emission 792.838 ms, Total 2952.838 ms +Execution Time: 80270.059 ms","Nested Loop (cost=9901244.21..9901244.32 rows=1 width=288) (actual time=79566.325..79571.304 rows=1 loops=1) + -> Nested Loop (cost=8269402.52..8269402.61 rows=1 width=240) (actual time=66339.559..66340.003 rows=1 loops=1) + -> Nested Loop (cost=6616087.20..6616087.27 rows=1 width=192) (actual time=53092.938..53093.301 rows=1 loops=1) + -> Nested Loop (cost=4958501.51..4958501.56 rows=1 width=144) (actual time=39861.263..39861.550 rows=1 loops=1) + -> Nested Loop (cost=3325776.92..3325776.95 rows=1 width=96) (actual time=26573.543..26573.753 rows=1 loops=1) + -> Aggregate (cost=1659529.39..1659529.40 rows=1 width=48) (actual time=13260.710..13260.835 rows=1 loops=1) + -> Gather Merge (cost=1599238.79..1655881.79 rows=486346 width=6) (actual time=13144.149..13216.266 rows=367014 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1598238.76..1598745.37 rows=202644 width=6) (actual time=13129.568..13144.954 rows=122338 loops=3) + Sort Key: store_sales.ss_list_price + Sort Method: external merge Disk: 1224kB + Worker 0: Sort Method: external merge Disk: 1328kB + Worker 1: Sort Method: external merge Disk: 1392kB + -> Parallel Seq Scan on store_sales (cost=0.00..1577605.12 rows=202644 width=6) (actual time=458.485..13079.596 rows=122338 loops=3) + Filter: ((ss_quantity <= 5) AND (ss_quantity >= 0) AND ((ss_coupon_amt <= '1459'::numeric) OR (ss_list_price <= '18'::numeric) OR (ss_wholesale_cost <= '77'::numeric)) AND ((ss_coupon_amt <= '1459'::numeric) OR (ss_list_price <= '18'::numeric) OR (ss_wholesale_cost >= '57'::numeric)) AND ((ss_coupon_amt <= '1459'::numeric) OR (ss_list_price >= '8'::numeric) OR (ss_wholesale_cost <= '77'::numeric)) AND ((ss_coupon_amt <= '1459'::numeric) OR (ss_list_price >= '8'::numeric) OR (ss_wholesale_cost >= '57'::numeric)) AND ((ss_coupon_amt >= '459'::numeric) OR (ss_list_price <= '18'::numeric) OR (ss_wholesale_cost <= '77'::numeric)) AND ((ss_coupon_amt >= '459'::numeric) OR (ss_list_price <= '18'::numeric) OR (ss_wholesale_cost >= '57'::numeric)) AND ((ss_coupon_amt >= '459'::numeric) OR (ss_list_price >= '8'::numeric) OR (ss_wholesale_cost <= '77'::numeric)) AND ((ss_coupon_amt >= '459'::numeric) OR (ss_list_price >= '8'::numeric) OR (ss_wholesale_cost >= '57'::numeric))) + Rows Removed by Filter: 9477992 + -> Aggregate (cost=1666247.53..1666247.54 rows=1 width=48) (actual time=13312.825..13312.908 rows=1 loops=1) + -> Gather Merge (cost=1601045.25..1662302.77 rows=525967 width=6) (actual time=13207.573..13271.879 rows=355872 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1600045.23..1600593.11 rows=219153 width=6) (actual time=13181.858..13194.592 rows=118624 loops=3) + Sort Key: store_sales_1.ss_list_price + Sort Method: external sort Disk: 1856kB + Worker 0: Sort Method: external merge Disk: 1224kB + Worker 1: Sort Method: external merge Disk: 1232kB + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..1577605.12 rows=219153 width=6) (actual time=137.459..13128.330 rows=118624 loops=3) + Filter: ((ss_quantity <= 10) AND (ss_quantity >= 6) AND ((ss_coupon_amt <= '3323'::numeric) OR (ss_list_price <= '100'::numeric) OR (ss_wholesale_cost <= '51'::numeric)) AND ((ss_coupon_amt <= '3323'::numeric) OR (ss_list_price <= '100'::numeric) OR (ss_wholesale_cost >= '31'::numeric)) AND ((ss_coupon_amt <= '3323'::numeric) OR (ss_list_price >= '90'::numeric) OR (ss_wholesale_cost <= '51'::numeric)) AND ((ss_coupon_amt <= '3323'::numeric) OR (ss_list_price >= '90'::numeric) OR (ss_wholesale_cost >= '31'::numeric)) AND ((ss_coupon_amt >= '2323'::numeric) OR (ss_list_price <= '100'::numeric) OR (ss_wholesale_cost <= '51'::numeric)) AND ((ss_coupon_amt >= '2323'::numeric) OR (ss_list_price <= '100'::numeric) OR (ss_wholesale_cost >= '31'::numeric)) AND ((ss_coupon_amt >= '2323'::numeric) OR (ss_list_price >= '90'::numeric) OR (ss_wholesale_cost <= '51'::numeric)) AND ((ss_coupon_amt >= '2323'::numeric) OR (ss_list_price >= '90'::numeric) OR (ss_wholesale_cost >= '31'::numeric))) + Rows Removed by Filter: 9481706 + -> Aggregate (cost=1632724.59..1632724.60 rows=1 width=48) (actual time=13287.713..13287.790 rows=1 loops=1) + -> Gather Merge (cost=1592115.77..1630267.74 rows=327579 width=6) (actual time=13193.442..13250.149 rows=282365 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1591115.75..1591456.97 rows=136491 width=6) (actual time=13172.143..13176.802 rows=94122 loops=3) + Sort Key: store_sales_2.ss_list_price + Sort Method: quicksort Memory: 3982kB + Worker 0: Sort Method: quicksort Memory: 3880kB + Worker 1: Sort Method: quicksort Memory: 3908kB + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..1577605.12 rows=136491 width=6) (actual time=154.545..13131.538 rows=94122 loops=3) + Filter: ((ss_quantity <= 15) AND (ss_quantity >= 11) AND ((ss_coupon_amt <= '13214'::numeric) OR (ss_list_price <= '152'::numeric) OR (ss_wholesale_cost <= '99'::numeric)) AND ((ss_coupon_amt <= '13214'::numeric) OR (ss_list_price <= '152'::numeric) OR (ss_wholesale_cost >= '79'::numeric)) AND ((ss_coupon_amt <= '13214'::numeric) OR (ss_list_price >= '142'::numeric) OR (ss_wholesale_cost <= '99'::numeric)) AND ((ss_coupon_amt <= '13214'::numeric) OR (ss_list_price >= '142'::numeric) OR (ss_wholesale_cost >= '79'::numeric)) AND ((ss_coupon_amt >= '12214'::numeric) OR (ss_list_price <= '152'::numeric) OR (ss_wholesale_cost <= '99'::numeric)) AND ((ss_coupon_amt >= '12214'::numeric) OR (ss_list_price <= '152'::numeric) OR (ss_wholesale_cost >= '79'::numeric)) AND ((ss_coupon_amt >= '12214'::numeric) OR (ss_list_price >= '142'::numeric) OR (ss_wholesale_cost <= '99'::numeric)) AND ((ss_coupon_amt >= '12214'::numeric) OR (ss_list_price >= '142'::numeric) OR (ss_wholesale_cost >= '79'::numeric))) + Rows Removed by Filter: 9506209 + -> Aggregate (cost=1657585.70..1657585.71 rows=1 width=48) (actual time=13231.667..13231.742 rows=1 loops=1) + -> Gather Merge (cost=1598716.99..1654024.12 rows=474876 width=6) (actual time=13139.024..13195.790 rows=319172 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1597716.96..1598211.63 rows=197865 width=6) (actual time=13115.218..13123.548 rows=106391 loops=3) + Sort Key: store_sales_3.ss_list_price + Sort Method: external sort Disk: 1624kB + Worker 0: Sort Method: quicksort Memory: 4020kB + Worker 1: Sort Method: external merge Disk: 1160kB + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..1577605.12 rows=197865 width=6) (actual time=139.369..13064.828 rows=106391 loops=3) + Filter: ((ss_quantity <= 20) AND (ss_quantity >= 16) AND ((ss_coupon_amt <= '7071'::numeric) OR (ss_list_price <= '145'::numeric) OR (ss_wholesale_cost <= '58'::numeric)) AND ((ss_coupon_amt <= '7071'::numeric) OR (ss_list_price <= '145'::numeric) OR (ss_wholesale_cost >= '38'::numeric)) AND ((ss_coupon_amt <= '7071'::numeric) OR (ss_list_price >= '135'::numeric) OR (ss_wholesale_cost <= '58'::numeric)) AND ((ss_coupon_amt <= '7071'::numeric) OR (ss_list_price >= '135'::numeric) OR (ss_wholesale_cost >= '38'::numeric)) AND ((ss_coupon_amt >= '6071'::numeric) OR (ss_list_price <= '145'::numeric) OR (ss_wholesale_cost <= '58'::numeric)) AND ((ss_coupon_amt >= '6071'::numeric) OR (ss_list_price <= '145'::numeric) OR (ss_wholesale_cost >= '38'::numeric)) AND ((ss_coupon_amt >= '6071'::numeric) OR (ss_list_price >= '135'::numeric) OR (ss_wholesale_cost <= '58'::numeric)) AND ((ss_coupon_amt >= '6071'::numeric) OR (ss_list_price >= '135'::numeric) OR (ss_wholesale_cost >= '38'::numeric))) + Rows Removed by Filter: 9493940 + -> Aggregate (cost=1653315.31..1653315.32 rows=1 width=48) (actual time=13246.613..13246.691 rows=1 loops=1) + -> Gather Merge (cost=1597574.77..1649942.99 rows=449642 width=6) (actual time=13130.209..13201.032 rows=365262 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1596574.75..1597043.13 rows=187351 width=6) (actual time=13103.260..13116.644 rows=121754 loops=3) + Sort Key: store_sales_4.ss_list_price + Sort Method: external sort Disk: 1856kB + Worker 0: Sort Method: external merge Disk: 1264kB + Worker 1: Sort Method: external merge Disk: 1296kB + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..1577605.12 rows=187351 width=6) (actual time=141.203..13048.348 rows=121754 loops=3) + Filter: ((ss_quantity <= 25) AND (ss_quantity >= 21) AND ((ss_coupon_amt <= '1836'::numeric) OR (ss_list_price <= '132'::numeric) OR (ss_wholesale_cost <= '37'::numeric)) AND ((ss_coupon_amt <= '1836'::numeric) OR (ss_list_price <= '132'::numeric) OR (ss_wholesale_cost >= '17'::numeric)) AND ((ss_coupon_amt <= '1836'::numeric) OR (ss_list_price >= '122'::numeric) OR (ss_wholesale_cost <= '37'::numeric)) AND ((ss_coupon_amt <= '1836'::numeric) OR (ss_list_price >= '122'::numeric) OR (ss_wholesale_cost >= '17'::numeric)) AND ((ss_coupon_amt >= '836'::numeric) OR (ss_list_price <= '132'::numeric) OR (ss_wholesale_cost <= '37'::numeric)) AND ((ss_coupon_amt >= '836'::numeric) OR (ss_list_price <= '132'::numeric) OR (ss_wholesale_cost >= '17'::numeric)) AND ((ss_coupon_amt >= '836'::numeric) OR (ss_list_price >= '122'::numeric) OR (ss_wholesale_cost <= '37'::numeric)) AND ((ss_coupon_amt >= '836'::numeric) OR (ss_list_price >= '122'::numeric) OR (ss_wholesale_cost >= '17'::numeric))) + Rows Removed by Filter: 9478576 + -> Aggregate (cost=1631841.69..1631841.70 rows=1 width=48) (actual time=13226.759..13231.293 rows=1 loops=1) + -> Gather Merge (cost=1591882.46..1629424.15 rows=322339 width=6) (actual time=13125.863..13191.862 rows=302090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1590882.43..1591218.20 rows=134308 width=6) (actual time=13106.147..13112.234 rows=100697 loops=3) + Sort Key: store_sales_5.ss_list_price + Sort Method: external sort Disk: 1568kB + Worker 0: Sort Method: quicksort Memory: 3928kB + Worker 1: Sort Method: quicksort Memory: 4025kB + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..1577605.12 rows=134308 width=6) (actual time=146.477..13059.194 rows=100697 loops=3) + Filter: ((ss_quantity <= 30) AND (ss_quantity >= 26) AND ((ss_coupon_amt <= '8326'::numeric) OR (ss_list_price <= '164'::numeric) OR (ss_wholesale_cost <= '27'::numeric)) AND ((ss_coupon_amt <= '8326'::numeric) OR (ss_list_price <= '164'::numeric) OR (ss_wholesale_cost >= '7'::numeric)) AND ((ss_coupon_amt <= '8326'::numeric) OR (ss_list_price >= '154'::numeric) OR (ss_wholesale_cost <= '27'::numeric)) AND ((ss_coupon_amt <= '8326'::numeric) OR (ss_list_price >= '154'::numeric) OR (ss_wholesale_cost >= '7'::numeric)) AND ((ss_coupon_amt >= '7326'::numeric) OR (ss_list_price <= '164'::numeric) OR (ss_wholesale_cost <= '27'::numeric)) AND ((ss_coupon_amt >= '7326'::numeric) OR (ss_list_price <= '164'::numeric) OR (ss_wholesale_cost >= '7'::numeric)) AND ((ss_coupon_amt >= '7326'::numeric) OR (ss_list_price >= '154'::numeric) OR (ss_wholesale_cost <= '27'::numeric)) AND ((ss_coupon_amt >= '7326'::numeric) OR (ss_list_price >= '154'::numeric) OR (ss_wholesale_cost >= '7'::numeric))) + Rows Removed by Filter: 9499634 +Planning Time: 0.955 ms +JIT: + Functions: 89 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 18.912 ms, Inlining 839.959 ms, Optimization 1653.503 ms, Emission 1022.493 ms, Total 3534.866 ms +Execution Time: 79577.159 ms",SUCCESS +42,43,TPCDS,Q29,"SELECT + i.i_item_id, + i.i_item_desc, + s.s_store_id, + s.s_store_name, + SUM(ss.ss_quantity) AS store_sales_quantity, + SUM(sr.sr_return_quantity) AS store_returns_quantity, + SUM(cs.cs_quantity) AS catalog_sales_quantity +FROM tpcds.store_sales ss +JOIN tpcds.date_dim d1 ON d1.d_date_sk = ss.ss_sold_date_sk +JOIN tpcds.item i ON i.i_item_sk = ss.ss_item_sk +JOIN tpcds.store s ON s.s_store_sk = ss.ss_store_sk +JOIN tpcds.store_returns sr ON sr.sr_customer_sk = ss.ss_customer_sk + AND sr.sr_item_sk = ss.ss_item_sk + AND sr.sr_ticket_number= ss.ss_ticket_number +JOIN tpcds.date_dim d2 ON d2.d_date_sk = sr.sr_returned_date_sk +JOIN tpcds.catalog_sales cs ON cs.cs_bill_customer_sk = sr.sr_customer_sk + AND cs.cs_item_sk = sr.sr_item_sk +JOIN tpcds.date_dim d3 ON d3.d_date_sk = cs.cs_sold_date_sk +WHERE d1.d_moy = 9 + AND d1.d_year = 1999 + -- returned in the next six months of the same year + AND d2.d_year = 1999 + AND d2.d_moy BETWEEN 9 AND 9 + 6 + -- re-purchased through catalog in the following three years + AND d3.d_year IN (1999, 2000, 2001) +GROUP BY + i.i_item_id, + i.i_item_desc, + s.s_store_id, + s.s_store_name +ORDER BY + i.i_item_id, + i.i_item_desc, + s.s_store_id, + s.s_store_name +LIMIT 100;","selected_returns = store_sales.WHERE( + (sold_date.month_of_year == 9) + & (sold_date.year == 1999) +).CALCULATE( + sale_customer_key=customer_key, + sale_item_key=item_key, + sale_ticket_number=ticket_number, + i_item_id=item._id, + i_item_desc=item.description, + s_store_id=store._id, + s_store_name=store.name, + sale_quantity=quantity +).CROSS(store_returns).WHERE( + (sale_customer_key==customer_key) + & (sale_item_key==item_key) + & (sale_ticket_number == ticket_number) + & (returned_date.year == 1999) + & MONOTONIC(9, returned_date.month_of_year, (9 + 6)) +) +re_bought_catalog = selected_returns.CALCULATE( + return_customer_key=customer_key, + return_item_key=item_key, + return_quantity=quantity +).CROSS(catalog_sales).WHERE( + (return_customer_key==bill_customer_key) + & (return_item_key==item_key) + & ISIN(sold_date.year, (1999, 2000, 2001)) +) +result = re_bought_catalog.PARTITION( + name='item_store_groups', by=(i_item_id, i_item_desc, s_store_id, s_store_name) +).CALCULATE( + i_item_id, + i_item_desc, + s_store_id, + s_store_name, + store_sales_quantity=SUM(catalog_sales.sale_quantity), + store_returns_quantity=SUM(catalog_sales.return_quantity), + catalog_sales_quantity=SUM(catalog_sales.quantity) +).TOP_K(100, by=(i_item_id, i_item_desc, s_store_id, s_store_name))","SELECT + item.i_item_id, + item.i_item_desc, + store.s_store_id, + store.s_store_name, + COALESCE(SUM(store_sales.ss_quantity), 0) AS store_sales_quantity, + COALESCE(SUM(store_returns.sr_return_quantity), 0) AS store_returns_quantity, + COALESCE(SUM(catalog_sales.cs_quantity), 0) AS catalog_sales_quantity +FROM tpcds.store_sales AS store_sales +JOIN tpcds.date_dim AS date_dim + ON date_dim.d_date_sk = store_sales.ss_sold_date_sk + AND date_dim.d_moy = 9 + AND date_dim.d_year = 1999 +JOIN tpcds.item AS item + ON item.i_item_sk = store_sales.ss_item_sk +LEFT JOIN tpcds.store AS store + ON store.s_store_sk = store_sales.ss_store_sk +JOIN tpcds.store_returns AS store_returns + ON store_returns.sr_customer_sk = store_sales.ss_customer_sk + AND store_returns.sr_item_sk = store_sales.ss_item_sk + AND store_returns.sr_ticket_number = store_sales.ss_ticket_number +JOIN tpcds.date_dim AS date_dim_2 + ON date_dim_2.d_date_sk = store_returns.sr_returned_date_sk + AND date_dim_2.d_moy <= 15 + AND date_dim_2.d_moy >= 9 + AND date_dim_2.d_year = 1999 +JOIN tpcds.catalog_sales AS catalog_sales + ON catalog_sales.cs_bill_customer_sk = store_returns.sr_customer_sk + AND catalog_sales.cs_item_sk = store_returns.sr_item_sk +LEFT JOIN tpcds.date_dim AS date_dim_3 + ON catalog_sales.cs_sold_date_sk = date_dim_3.d_date_sk +WHERE + date_dim_3.d_year IN (1999, 2000, 2001) +GROUP BY + 1, + 2, + 3, + 4 +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST, + 4 NULLS FIRST +LIMIT 100",26.29143139900043,25.825060182000016,"Limit (cost=937253.39..1534184.79 rows=1 width=236) (actual time=25038.349..26448.879 rows=8 loops=1) + -> GroupAggregate (cost=937253.39..1534184.79 rows=1 width=236) (actual time=24643.022..26053.549 rows=8 loops=1) + Group Key: i.i_item_id, i.i_item_desc, s.s_store_id, s.s_store_name + -> Nested Loop (cost=937253.39..1534184.76 rows=1 width=164) (actual time=24211.243..26053.483 rows=8 loops=1) + Join Filter: ((i.i_item_sk = sr.sr_item_sk) AND (ss.ss_customer_sk = sr.sr_customer_sk) AND (ss.ss_ticket_number = sr.sr_ticket_number)) + Rows Removed by Join Filter: 21332009 + -> Gather Merge (cost=851759.40..853015.38 rows=10784 width=180) (actual time=13986.147..14341.063 rows=576541 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=850759.38..850770.61 rows=4493 width=180) (actual time=13879.114..13948.809 rows=192180 loops=3) + Sort Key: i.i_item_id, i.i_item_desc, s.s_store_id, s.s_store_name + Sort Method: external merge Disk: 52888kB + Worker 0: Sort Method: external merge Disk: 29840kB + Worker 1: Sort Method: external merge Disk: 27768kB + -> Parallel Hash Join (cost=845379.71..850486.80 rows=4493 width=180) (actual time=13129.703..13189.680 rows=192180 loops=3) + Hash Cond: (i.i_item_sk = ss.ss_item_sk) + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=127) (actual time=0.024..9.465 rows=34000 loops=3) + -> Parallel Hash (cost=845323.54..845323.54 rows=4493 width=53) (actual time=13100.282..13100.286 rows=192180 loops=3) + Buckets: 131072 (originally 16384) Batches: 8 (originally 1) Memory Usage: 7264kB + -> Hash Join (cost=2684.07..845323.54 rows=4493 width=53) (actual time=182.364..12969.298 rows=192180 loops=3) + Hash Cond: (ss.ss_store_sk = s.s_store_sk) + -> Parallel Hash Join (cost=2676.78..845253.67 rows=4704 width=40) (actual time=3.102..12748.555 rows=196794 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d1.d_date_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=48) (actual time=0.169..11897.256 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=2.437..2.438 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d1 (cost=0.00..2676.55 rows=18 width=8) (actual time=3.684..7.291 rows=30 loops=1) + Filter: ((d_moy = 9) AND (d_year = 1999)) + Rows Removed by Filter: 73019 + -> Hash (cost=6.02..6.02 rows=102 width=29) (actual time=179.244..179.244 rows=102 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 15kB + -> Seq Scan on store s (cost=0.00..6.02 rows=102 width=29) (actual time=179.192..179.220 rows=102 loops=3) + -> Materialize (cost=85493.99..680953.70 rows=1 width=56) (actual time=0.001..0.019 rows=37 loops=576541) + -> Gather (cost=85493.99..680953.70 rows=1 width=56) (actual time=500.833..10008.309 rows=37 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=84493.99..679953.60 rows=1 width=56) (actual time=723.788..9985.329 rows=12 loops=3) + Hash Cond: ((cs.cs_item_sk = sr.sr_item_sk) AND (cs.cs_bill_customer_sk = sr.sr_customer_sk)) + -> Parallel Hash Join (cost=2630.89..597419.30 rows=89492 width=24) (actual time=3.743..9038.888 rows=2856999 loops=3) + Hash Cond: (cs.cs_sold_date_sk = d3.d_date_sk) + -> Parallel Seq Scan on catalog_sales cs (cost=0.00..571759.33 rows=6000733 width=32) (actual time=0.142..8265.562 rows=4800420 loops=3) + -> Parallel Hash (cost=2622.84..2622.84 rows=644 width=8) (actual time=3.544..3.545 rows=365 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 112kB + -> Parallel Seq Scan on date_dim d3 (cost=0.00..2622.84 rows=644 width=8) (actual time=1.773..3.426 rows=365 loops=3) + Filter: (d_year = ANY ('{1999,2000,2001}'::bigint[])) + Rows Removed by Filter: 23984 + -> Parallel Hash (cost=81834.11..81834.11 rows=1933 width=32) (actual time=474.340..474.342 rows=61011 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 15296kB + -> Parallel Hash Join (cost=2784.88..81834.11 rows=1933 width=32) (actual time=162.492..360.143 rows=61011 loops=3) + Hash Cond: (sr.sr_returned_date_sk = d2.d_date_sk) + -> Parallel Seq Scan on store_returns sr (cost=0.00..74541.69 rows=1198969 width=40) (actual time=0.022..110.349 rows=959177 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=72 width=8) (actual time=1.953..1.953 rows=41 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d2 (cost=0.00..2783.97 rows=72 width=8) (actual time=3.001..5.834 rows=122 loops=1) + Filter: ((d_moy >= 9) AND (d_moy <= 15) AND (d_year = 1999)) + Rows Removed by Filter: 72927 +Planning Time: 5.232 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 9.075 ms, Inlining 235.797 ms, Optimization 697.054 ms, Emission 481.920 ms, Total 1423.845 ms +Execution Time: 26458.931 ms","Limit (cost=937271.27..1534271.58 rows=1 width=236) (actual time=25574.929..27142.696 rows=8 loops=1) + -> GroupAggregate (cost=937271.27..1534271.58 rows=1 width=236) (actual time=25188.284..26756.048 rows=8 loops=1) + Group Key: item.i_item_id, item.i_item_desc, store.s_store_id, store.s_store_name + -> Nested Loop (cost=937271.27..1534271.55 rows=1 width=164) (actual time=24699.226..26755.980 rows=8 loops=1) + Join Filter: ((item.i_item_sk = store_returns.sr_item_sk) AND (store_sales.ss_customer_sk = store_returns.sr_customer_sk) AND (store_sales.ss_ticket_number = store_returns.sr_ticket_number)) + Rows Removed by Join Filter: 21844089 + -> Gather Merge (cost=851777.28..853092.07 rows=11289 width=180) (actual time=14008.900..14540.207 rows=590381 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=850777.26..850789.02 rows=4704 width=180) (actual time=13899.752..14040.254 rows=196794 loops=3) + Sort Key: item.i_item_id NULLS FIRST, item.i_item_desc NULLS FIRST, store.s_store_id NULLS FIRST, store.s_store_name NULLS FIRST + Sort Method: external merge Disk: 29824kB + Worker 0: Sort Method: external merge Disk: 53160kB + Worker 1: Sort Method: external merge Disk: 29872kB + -> Hash Left Join (cost=845319.76..850490.32 rows=4704 width=180) (actual time=13091.938..13184.934 rows=196794 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=845312.47..850420.44 rows=4704 width=167) (actual time=13091.862..13150.629 rows=196794 loops=3) + Hash Cond: (item.i_item_sk = store_sales.ss_item_sk) + -> Parallel Seq Scan on item (cost=0.00..4929.00 rows=42500 width=127) (actual time=0.022..9.215 rows=34000 loops=3) + -> Parallel Hash (cost=845253.67..845253.67 rows=4704 width=40) (actual time=13063.155..13063.158 rows=196794 loops=3) + Buckets: 131072 (originally 16384) Batches: 8 (originally 1) Memory Usage: 6240kB + -> Parallel Hash Join (cost=2676.78..845253.67 rows=4704 width=40) (actual time=177.833..12908.404 rows=196794 loops=3) + Hash Cond: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797545.22 rows=12000922 width=48) (actual time=0.006..11893.121 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=2.531..2.531 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=18 width=8) (actual time=3.748..7.574 rows=30 loops=1) + Filter: ((d_moy = 9) AND (d_year = 1999)) + Rows Removed by Filter: 73019 + -> Hash (cost=6.02..6.02 rows=102 width=29) (actual time=0.060..0.060 rows=102 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 15kB + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=29) (actual time=0.017..0.037 rows=102 loops=3) + -> Materialize (cost=85493.99..680953.70 rows=1 width=56) (actual time=0.001..0.019 rows=37 loops=590381) + -> Gather (cost=85493.99..680953.70 rows=1 width=56) (actual time=466.248..10445.363 rows=37 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=84493.99..679953.60 rows=1 width=56) (actual time=564.005..10426.103 rows=12 loops=3) + Hash Cond: ((catalog_sales.cs_item_sk = store_returns.sr_item_sk) AND (catalog_sales.cs_bill_customer_sk = store_returns.sr_customer_sk)) + -> Parallel Hash Join (cost=2630.89..597419.30 rows=89492 width=24) (actual time=4.012..9504.632 rows=2856999 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim_3.d_date_sk) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571759.33 rows=6000733 width=32) (actual time=0.133..8728.524 rows=4800420 loops=3) + -> Parallel Hash (cost=2622.84..2622.84 rows=644 width=8) (actual time=3.822..3.823 rows=365 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 112kB + -> Parallel Seq Scan on date_dim date_dim_3 (cost=0.00..2622.84 rows=644 width=8) (actual time=1.909..3.715 rows=365 loops=3) + Filter: (d_year = ANY ('{1999,2000,2001}'::bigint[])) + Rows Removed by Filter: 23984 + -> Parallel Hash (cost=81834.11..81834.11 rows=1933 width=32) (actual time=442.643..442.645 rows=61011 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 15296kB + -> Parallel Hash Join (cost=2784.88..81834.11 rows=1933 width=32) (actual time=146.840..347.004 rows=61011 loops=3) + Hash Cond: (store_returns.sr_returned_date_sk = date_dim_2.d_date_sk) + -> Parallel Seq Scan on store_returns (cost=0.00..74541.69 rows=1198969 width=40) (actual time=0.020..109.504 rows=959177 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=72 width=8) (actual time=2.681..2.682 rows=41 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim date_dim_2 (cost=0.00..2783.97 rows=72 width=8) (actual time=4.212..8.010 rows=122 loops=1) + Filter: ((d_moy <= 15) AND (d_moy >= 9) AND (d_year = 1999)) + Rows Removed by Filter: 72927 +Planning Time: 5.080 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.547 ms, Inlining 222.029 ms, Optimization 689.184 ms, Emission 433.575 ms, Total 1353.335 ms +Execution Time: 27146.421 ms",SUCCESS +43,44,TPCDS,Q30,"WITH customer_total_return AS ( + SELECT + wr.wr_returning_customer_sk AS ctr_customer_sk, + ca.ca_state AS ctr_state, + SUM(wr.wr_return_amt) AS ctr_total_return + FROM tpcds.web_returns wr + JOIN tpcds.date_dim d + ON wr.wr_returned_date_sk = d.d_date_sk + JOIN tpcds.customer_address ca + ON wr.wr_returning_addr_sk = ca.ca_address_sk + WHERE d.d_year = 2002 + GROUP BY + wr.wr_returning_customer_sk, + ca.ca_state +), +customer_with_avg AS ( + SELECT + ctr.*, + AVG(ctr_total_return) OVER (PARTITION BY ctr_state) AS state_avg_return + FROM customer_total_return ctr +) +SELECT + c.c_customer_id, + c.c_salutation, + c.c_first_name, + c.c_last_name, + c.c_preferred_cust_flag, + c.c_birth_day, + c.c_birth_month, + c.c_birth_year, + c.c_birth_country, + c.c_login, + c.c_email_address, + c.c_last_review_date_sk, + cwa.ctr_total_return +FROM customer_with_avg cwa +JOIN tpcds.customer c + ON cwa.ctr_customer_sk = c.c_customer_sk +JOIN tpcds.customer_address ca + ON ca.ca_address_sk = c.c_current_addr_sk +WHERE cwa.ctr_total_return > cwa.state_avg_return * 1.2 + AND ca.ca_state = 'GA' +ORDER BY + c.c_customer_id, + c.c_salutation, + c.c_first_name, + c.c_last_name, + c.c_preferred_cust_flag, + c.c_birth_day, + c.c_birth_month, + c.c_birth_year, + c.c_birth_country, + c.c_login, + c.c_email_address, + c.c_last_review_date_sk, + cwa.ctr_total_return +LIMIT 100;","customer_access = CROSS(customers).WHERE( + (returning_customer_key==key) +).SINGULAR() +result = web_returns.WHERE( + HAS(returned_date) + & (returned_date.year == 2002) +).CALCULATE( + returning_customer_key, + returning_state=DEFAULT_TO(returning_address.state, 'UNKNOWN') +).PARTITION( + name='customer_returning_state_groups', + by=(returning_customer_key, returning_state) +).CALCULATE( + returning_customer_key, + returning_state, + c_total_return=SUM(web_returns.return_amount) +).WHERE(COUNT(web_returns.return_amount) > 0).PARTITION( + name='returing_state_groups', by=returning_state +).customer_returning_state_groups.CALCULATE( + returning_customer_key, + returning_state, + c_total_return, + state_avg=RELAVG(c_total_return, per='returing_state_groups') +).WHERE( + (c_total_return > 1.2 * state_avg) +).CALCULATE( + returning_customer_key +).CALCULATE( + c_customer_id=customer_access._id, + c_salutation=customer_access.salutation, + c_first_name=customer_access.first_name, + c_last_name=customer_access.last_name, + c_preferred_cust_flag=customer_access.preferred_customer_flag, + c_birth_day=customer_access.birth_day, + c_birth_month=customer_access.birth_month, + c_birth_year=customer_access.birth_year, + c_birth_country=customer_access.birth_country, + c_login=customer_access.login, + c_email_address=customer_access.email, + c_last_review_date_sk=customer_access.last_review_date_key, + ctr_total_return=c_total_return +).WHERE( + (customer_access.current_address.state == 'GA') +).TOP_K(100, by=( + c_customer_id, + c_salutation, + c_first_name, + c_last_name, + c_preferred_cust_flag, + c_birth_day, + c_birth_month, + c_birth_year, + c_birth_country, + c_login, + c_email_address, + c_last_review_date_sk, + ctr_total_return + ) +)","WITH _s0 AS ( + SELECT + wr_return_amt, + wr_returned_date_sk, + wr_returning_addr_sk, + wr_returning_customer_sk + FROM tpcds.web_returns +), _t5 AS ( + SELECT + d_date_sk, + d_year + FROM tpcds.date_dim + WHERE + d_year = 2002 +), _s3 AS ( + SELECT + ca_address_sk, + ca_state + FROM tpcds.customer_address +), _t3 AS ( + SELECT + COALESCE(_s3.ca_state, 'UNKNOWN') AS returning_state, + _s0.wr_returning_customer_sk, + COUNT(_s0.wr_return_amt) AS count_wr_return_amt, + SUM(_s0.wr_return_amt) AS sum_wr_return_amt + FROM _s0 AS _s0 + JOIN _t5 AS _t5 + ON _s0.wr_returned_date_sk = _t5.d_date_sk + LEFT JOIN _s3 AS _s3 + ON _s0.wr_returning_addr_sk = _s3.ca_address_sk + GROUP BY + 1, + 2 +), _t1 AS ( + SELECT + returning_state, + sum_wr_return_amt, + wr_returning_customer_sk, + AVG(CAST(COALESCE(sum_wr_return_amt, 0) AS DOUBLE PRECISION)) OVER (PARTITION BY returning_state) AS state_avg + FROM _t3 + WHERE + count_wr_return_amt > 0 +), _t8 AS ( + SELECT + COALESCE(_s7.ca_state, 'UNKNOWN') AS returning_state, + _s4.wr_returning_customer_sk, + COUNT(_s4.wr_return_amt) AS count_wr_return_amt, + SUM(_s4.wr_return_amt) AS sum_wr_return_amt + FROM _s0 AS _s4 + JOIN _t5 AS _t10 + ON _s4.wr_returned_date_sk = _t10.d_date_sk + LEFT JOIN _s3 AS _s7 + ON _s4.wr_returning_addr_sk = _s7.ca_address_sk + GROUP BY + 1, + 2 +), _t6 AS ( + SELECT + returning_state, + sum_wr_return_amt, + wr_returning_customer_sk, + AVG(CAST(COALESCE(sum_wr_return_amt, 0) AS DOUBLE PRECISION)) OVER (PARTITION BY returning_state) AS state_avg + FROM _t8 + WHERE + count_wr_return_amt > 0 +) +SELECT + customer.c_customer_id, + customer.c_salutation, + customer.c_first_name, + customer.c_last_name, + customer.c_preferred_cust_flag, + customer.c_birth_day, + customer.c_birth_month, + customer.c_birth_year, + customer.c_birth_country, + customer.c_login, + customer.c_email_address, + customer.c_last_review_date_sk, + COALESCE(_t1.sum_wr_return_amt, 0) AS ctr_total_return +FROM _t1 AS _t1 +JOIN _t6 AS _t6 + ON ( + 1.2 * _t6.state_avg + ) < COALESCE(_t6.sum_wr_return_amt, 0) + AND _t1.returning_state = _t6.returning_state + AND _t1.wr_returning_customer_sk = _t6.wr_returning_customer_sk +JOIN tpcds.customer AS customer + ON _t6.wr_returning_customer_sk = customer.c_customer_sk +JOIN tpcds.customer_address AS customer_address + ON customer.c_current_addr_sk = customer_address.ca_address_sk + AND customer_address.ca_state = 'GA' +WHERE + ( + 1.2 * _t1.state_avg + ) < COALESCE(_t1.sum_wr_return_amt, 0) +ORDER BY + 1 NULLS FIRST, + 2 NULLS FIRST, + 3 NULLS FIRST, + 4 NULLS FIRST, + 5 NULLS FIRST, + 6 NULLS FIRST, + 7 NULLS FIRST, + 8 NULLS FIRST, + 9 NULLS FIRST, + 10 NULLS FIRST, + 11 NULLS FIRST, + 12 NULLS FIRST, + 13 NULLS FIRST +LIMIT 100",0.6912609739993059,4.477377752000393,"Limit (cost=57053.99..57054.12 rows=51 width=134) (actual time=494.202..496.791 rows=100 loops=1) + -> Sort (cost=57053.99..57054.12 rows=51 width=134) (actual time=494.201..496.784 rows=100 loops=1) + Sort Key: c.c_customer_id, c.c_salutation, c.c_first_name, c.c_last_name, c.c_preferred_cust_flag, c.c_birth_day, c.c_birth_month, c.c_birth_year, c.c_birth_country, c.c_login, c.c_email_address, c.c_last_review_date_sk, cwa.ctr_total_return + Sort Method: top-N heapsort Memory: 60kB + -> Hash Join (cost=56941.47..57052.54 rows=51 width=134) (actual time=407.912..495.457 rows=1617 loops=1) + Hash Cond: (cwa.ctr_customer_sk = c.c_customer_sk) + -> Subquery Scan on cwa (cost=32665.08..32771.55 rows=1092 width=40) (actual time=330.868..413.142 rows=33338 loops=1) + Filter: (cwa.ctr_total_return > (cwa.state_avg_return * 1.2)) + Rows Removed by Filter: 98417 + -> WindowAgg (cost=32665.08..32722.41 rows=3276 width=75) (actual time=330.860..389.004 rows=131755 loops=1) + -> Sort (cost=32665.08..32673.27 rows=3276 width=43) (actual time=330.557..346.914 rows=131755 loops=1) + Sort Key: ctr.ctr_state + Sort Method: external merge Disk: 4216kB + -> Subquery Scan on ctr (cost=32059.73..32473.80 rows=3276 width=43) (actual time=139.268..283.532 rows=131755 loops=1) + -> Finalize GroupAggregate (cost=32059.73..32473.80 rows=3276 width=43) (actual time=139.267..271.885 rows=131755 loops=1) + Group Key: wr.wr_returning_customer_sk, ca_1.ca_state + -> Gather Merge (cost=32059.73..32405.55 rows=2730 width=43) (actual time=139.260..190.464 rows=132196 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=31059.70..31090.41 rows=1365 width=43) (actual time=124.808..156.780 rows=44065 loops=3) + Group Key: wr.wr_returning_customer_sk, ca_1.ca_state + -> Sort (cost=31059.70..31063.11 rows=1365 width=17) (actual time=124.797..128.990 rows=44708 loops=3) + Sort Key: wr.wr_returning_customer_sk, ca_1.ca_state + Sort Method: quicksort Memory: 3233kB + Worker 0: Sort Method: quicksort Memory: 3976kB + Worker 1: Sort Method: quicksort Memory: 3115kB + -> Parallel Hash Join (cost=25062.64..30988.62 rows=1365 width=17) (actual time=83.332..112.797 rows=44708 loops=3) + Hash Cond: (ca_1.ca_address_sk = wr.wr_returning_addr_sk) + -> Parallel Seq Scan on customer_address ca_1 (cost=0.00..5529.67 rows=104167 width=11) (actual time=0.017..8.946 rows=83333 loops=3) + -> Parallel Hash (cost=25044.78..25044.78 rows=1429 width=22) (actual time=83.100..83.103 rows=45790 loops=3) + Buckets: 262144 (originally 4096) Batches: 1 (originally 1) Memory Usage: 11424kB + -> Parallel Hash Join (cost=2571.81..25044.78 rows=1429 width=22) (actual time=3.384..65.505 rows=45790 loops=3) + Hash Cond: (wr.wr_returned_date_sk = d.d_date_sk) + -> Parallel Seq Scan on web_returns wr (cost=0.00..21340.76 rows=299676 width=30) (actual time=0.021..29.949 rows=239741 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=215 width=8) (actual time=3.349..3.349 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=215 width=8) (actual time=4.942..9.974 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 + -> Hash (cost=23982.21..23982.21 rows=23534 width=110) (actual time=77.018..77.280 rows=24415 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 3803kB + -> Gather (cost=6851.37..23982.21 rows=23534 width=110) (actual time=27.110..72.866 rows=24415 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5851.37..20628.81 rows=9806 width=110) (actual time=12.436..58.081 rows=8138 loops=3) + Hash Cond: (c.c_current_addr_sk = ca.ca_address_sk) + -> Parallel Seq Scan on customer c (cost=0.00..13955.33 rows=208333 width=118) (actual time=0.015..20.677 rows=166667 loops=3) + -> Parallel Hash (cost=5790.08..5790.08 rows=4903 width=8) (actual time=12.030..12.031 rows=4029 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 672kB + -> Parallel Seq Scan on customer_address ca (cost=0.00..5790.08 rows=4903 width=8) (actual time=0.033..11.317 rows=4029 loops=3) + Filter: ((ca_state)::text = 'GA'::text) + Rows Removed by Filter: 79304 +Planning Time: 0.357 ms +Execution Time: 497.397 ms","Limit (cost=468839379.01..470359095.54 rows=23 width=134) (actual time=3883.495..6794.816 rows=100 loops=1) + CTE _s0 + -> Seq Scan on web_returns (cost=0.00..25536.22 rows=719222 width=30) (actual time=0.010..100.775 rows=719222 loops=1) + CTE _t5 + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=365 width=16) (actual time=2.447..4.751 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 + CTE _s3 + -> Seq Scan on customer_address customer_address_1 (cost=0.00..6988.00 rows=250000 width=11) (actual time=0.033..29.696 rows=250000 loops=1) + -> Incremental Sort (cost=468803909.67..470323626.21 rows=23 width=134) (actual time=3265.454..6176.766 rows=100 loops=1) + Sort Key: customer.c_customer_id NULLS FIRST, customer.c_salutation NULLS FIRST, customer.c_first_name NULLS FIRST, customer.c_last_name NULLS FIRST, customer.c_preferred_cust_flag NULLS FIRST, customer.c_birth_day NULLS FIRST, customer.c_birth_month NULLS FIRST, customer.c_birth_year NULLS FIRST, customer.c_birth_country NULLS FIRST, customer.c_login NULLS FIRST, customer.c_email_address NULLS FIRST, customer.c_last_review_date_sk NULLS FIRST, (COALESCE(_t1.sum_wr_return_amt, '0'::numeric)) NULLS FIRST + Presorted Key: customer.c_customer_id, customer.c_salutation, customer.c_first_name, customer.c_last_name, customer.c_preferred_cust_flag, customer.c_birth_day, customer.c_birth_month, customer.c_birth_year, customer.c_birth_country, customer.c_login, customer.c_email_address, customer.c_last_review_date_sk + Full-sort Groups: 4 Sort Method: quicksort Average Memory: 32kB Peak Memory: 32kB + -> Nested Loop (cost=468734831.69..470323625.17 rows=23 width=134) (actual time=1818.276..6176.615 rows=101 loops=1) + Join Filter: (((_t1.returning_state)::text = (_t6.returning_state)::text) AND (_t1.wr_returning_customer_sk = _t6.wr_returning_customer_sk)) + Rows Removed by Join Filter: 3368184 + -> Nested Loop (cost=234378555.32..235950583.78 rows=209 width=182) (actual time=1259.328..5311.900 rows=101 loops=1) + Join Filter: (_t1.wr_returning_customer_sk = customer.c_customer_sk) + Rows Removed by Join Filter: 51184096 + -> Gather Merge (cost=22278.95..25019.87 rows=23534 width=110) (actual time=386.106..393.540 rows=1533 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=21278.92..21303.44 rows=9806 width=110) (actual time=365.240..365.347 rows=765 loops=3) + Sort Key: customer.c_customer_id NULLS FIRST, customer.c_salutation NULLS FIRST, customer.c_first_name NULLS FIRST, customer.c_last_name NULLS FIRST, customer.c_preferred_cust_flag NULLS FIRST, customer.c_birth_day NULLS FIRST, customer.c_birth_month NULLS FIRST, customer.c_birth_year NULLS FIRST, customer.c_birth_country NULLS FIRST, customer.c_login NULLS FIRST, customer.c_email_address NULLS FIRST, customer.c_last_review_date_sk NULLS FIRST + Sort Method: quicksort Memory: 1232kB + Worker 0: Sort Method: quicksort Memory: 1737kB + Worker 1: Sort Method: quicksort Memory: 1157kB + -> Parallel Hash Join (cost=5851.37..20628.81 rows=9806 width=110) (actual time=290.526..333.578 rows=8138 loops=3) + Hash Cond: (customer.c_current_addr_sk = customer_address.ca_address_sk) + -> Parallel Seq Scan on customer (cost=0.00..13955.33 rows=208333 width=118) (actual time=0.025..20.487 rows=166667 loops=3) + -> Parallel Hash (cost=5790.08..5790.08 rows=4903 width=8) (actual time=290.192..290.193 rows=4029 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 672kB + -> Parallel Seq Scan on customer_address (cost=0.00..5790.08 rows=4903 width=8) (actual time=187.311..195.946 rows=4029 loops=3) + Filter: ((ca_state)::text = 'GA'::text) + Rows Removed by Filter: 79304 + -> Materialize (cost=234356276.37..234356798.58 rows=4444 width=72) (actual time=0.497..1.893 rows=33388 loops=1533) + -> Subquery Scan on _t1 (cost=234356276.37..234356776.36 rows=4444 width=72) (actual time=762.180..855.793 rows=33391 loops=1) + Filter: (('1.2'::double precision * _t1.state_avg) < (COALESCE(_t1.sum_wr_return_amt, '0'::numeric))::double precision) + Rows Removed by Filter: 98396 + -> WindowAgg (cost=234356276.37..234356543.03 rows=13333 width=80) (actual time=762.174..831.338 rows=131787 loops=1) + -> Sort (cost=234356276.37..234356309.70 rows=13333 width=72) (actual time=761.779..776.250 rows=131787 loops=1) + Sort Key: _t3.returning_state + Sort Method: external merge Disk: 4344kB + -> Subquery Scan on _t3 (cost=202309219.39..234355362.88 rows=13333 width=72) (actual time=612.508..717.296 rows=131787 loops=1) + -> HashAggregate (cost=202309219.39..234355229.55 rows=13333 width=80) (actual time=612.504..708.191 rows=131787 loops=1) + Group Key: COALESCE(_s3.ca_state, 'UNKNOWN'::character varying), _s0.wr_returning_customer_sk + Filter: (count(_s0.wr_return_amt) > 0) + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 7160kB + Rows Removed by Filter: 1630 + -> Merge Right Join (cost=290422.32..24905828.77 rows=1640725000 width=54) (actual time=486.042..566.593 rows=137371 loops=1) + Merge Cond: (_s3.ca_address_sk = _s0.wr_returning_addr_sk) + -> Sort (cost=32541.96..33166.96 rows=250000 width=20) (actual time=110.229..129.045 rows=249999 loops=1) + Sort Key: _s3.ca_address_sk + Sort Method: external merge Disk: 6320kB + -> CTE Scan on _s3 (cost=0.00..5000.00 rows=250000 width=20) (actual time=0.040..76.995 rows=250000 loops=1) + -> Materialize (cost=257880.36..264443.26 rows=1312580 width=30) (actual time=375.763..401.397 rows=137371 loops=1) + -> Sort (cost=257880.36..261161.81 rows=1312580 width=30) (actual time=375.761..388.982 rows=137371 loops=1) + Sort Key: _s0.wr_returning_addr_sk + Sort Method: external merge Disk: 4512kB + -> Hash Join (cost=11.86..61685.15 rows=1312580 width=30) (actual time=4.893..342.127 rows=137371 loops=1) + Hash Cond: (_s0.wr_returned_date_sk = _t5.d_date_sk) + -> CTE Scan on _s0 (cost=0.00..14384.44 rows=719222 width=38) (actual time=0.011..269.451 rows=719222 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=4.864..4.864 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 (cost=0.00..7.30 rows=365 width=8) (actual time=2.450..4.815 rows=365 loops=1) + -> Materialize (cost=234356276.37..234356798.58 rows=4444 width=40) (actual time=4.654..6.862 rows=33349 loops=101) + -> Subquery Scan on _t6 (cost=234356276.37..234356776.36 rows=4444 width=40) (actual time=470.049..564.675 rows=33391 loops=1) + Filter: (('1.2'::double precision * _t6.state_avg) < (COALESCE(_t6.sum_wr_return_amt, '0'::numeric))::double precision) + Rows Removed by Filter: 98396 + -> WindowAgg (cost=234356276.37..234356543.03 rows=13333 width=80) (actual time=470.042..539.556 rows=131787 loops=1) + -> Sort (cost=234356276.37..234356309.70 rows=13333 width=72) (actual time=469.588..484.207 rows=131787 loops=1) + Sort Key: _t8.returning_state + Sort Method: external merge Disk: 4344kB + -> Subquery Scan on _t8 (cost=202309219.39..234355362.88 rows=13333 width=72) (actual time=321.288..424.376 rows=131787 loops=1) + -> HashAggregate (cost=202309219.39..234355229.55 rows=13333 width=80) (actual time=321.284..415.279 rows=131787 loops=1) + Group Key: COALESCE(_s7.ca_state, 'UNKNOWN'::character varying), _s4.wr_returning_customer_sk + Filter: (count(_s4.wr_return_amt) > 0) + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 7160kB + Rows Removed by Filter: 1630 + -> Merge Right Join (cost=290422.32..24905828.77 rows=1640725000 width=54) (actual time=195.666..276.333 rows=137371 loops=1) + Merge Cond: (_s7.ca_address_sk = _s4.wr_returning_addr_sk) + -> Sort (cost=32541.96..33166.96 rows=250000 width=20) (actual time=52.792..71.786 rows=249999 loops=1) + Sort Key: _s7.ca_address_sk + Sort Method: external merge Disk: 6320kB + -> CTE Scan on _s3 _s7 (cost=0.00..5000.00 rows=250000 width=20) (actual time=0.019..20.238 rows=250000 loops=1) + -> Materialize (cost=257880.36..264443.26 rows=1312580 width=30) (actual time=142.843..168.579 rows=137371 loops=1) + -> Sort (cost=257880.36..261161.81 rows=1312580 width=30) (actual time=142.842..156.113 rows=137371 loops=1) + Sort Key: _s4.wr_returning_addr_sk + Sort Method: external merge Disk: 4512kB + -> Hash Join (cost=11.86..61685.15 rows=1312580 width=30) (actual time=0.090..112.046 rows=137371 loops=1) + Hash Cond: (_s4.wr_returned_date_sk = _t10.d_date_sk) + -> CTE Scan on _s0 _s4 (cost=0.00..14384.44 rows=719222 width=38) (actual time=0.012..50.452 rows=719222 loops=1) + -> Hash (cost=7.30..7.30 rows=365 width=8) (actual time=0.064..0.065 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 _t10 (cost=0.00..7.30 rows=365 width=8) (actual time=0.004..0.028 rows=365 loops=1) +Planning Time: 0.502 ms +JIT: + Functions: 138 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.274 ms, Inlining 144.064 ms, Optimization 668.754 ms, Emission 446.828 ms, Total 1266.919 ms +Execution Time: 6808.617 ms",SUCCESS +44,45,TPCDS,Q31,"WITH ss AS ( + SELECT + ca.ca_county, + d.d_qoy, + d.d_year, + SUM(ss.ss_ext_sales_price) AS store_sales + FROM tpcds.store_sales ss + JOIN tpcds.date_dim d + ON ss.ss_sold_date_sk = d.d_date_sk + JOIN tpcds.customer_address ca + ON ss.ss_addr_sk = ca.ca_address_sk + GROUP BY + ca.ca_county, + d.d_qoy, + d.d_year +), +ws AS ( + SELECT + ca.ca_county, + d.d_qoy, + d.d_year, + SUM(ws.ws_ext_sales_price) AS web_sales + FROM tpcds.web_sales ws + JOIN tpcds.date_dim d + ON ws.ws_sold_date_sk = d.d_date_sk + JOIN tpcds.customer_address ca + ON ws.ws_bill_addr_sk = ca.ca_address_sk + GROUP BY + ca.ca_county, + d.d_qoy, + d.d_year +) +SELECT + ss1.ca_county, + ss1.d_year, + ws2.web_sales / ws1.web_sales AS web_q1_q2_increase, + ss2.store_sales / ss1.store_sales AS store_q1_q2_increase, + ws3.web_sales / ws2.web_sales AS web_q2_q3_increase, + ss3.store_sales / ss2.store_sales AS store_q2_q3_increase +FROM ss ss1 +JOIN ss ss2 + ON ss1.ca_county = ss2.ca_county +JOIN ss ss3 + ON ss2.ca_county = ss3.ca_county +JOIN ws ws1 + ON ss1.ca_county = ws1.ca_county +JOIN ws ws2 + ON ws1.ca_county = ws2.ca_county +JOIN ws ws3 + ON ws1.ca_county = ws3.ca_county +WHERE ss1.d_qoy = 1 + AND ss1.d_year = 2000 + AND ss2.d_qoy = 2 + AND ss2.d_year = 2000 + AND ss3.d_qoy = 3 + AND ss3.d_year = 2000 + AND ws1.d_qoy = 1 + AND ws1.d_year = 2000 + AND ws2.d_qoy = 2 + AND ws2.d_year = 2000 + AND ws3.d_qoy = 3 + AND ws3.d_year = 2000 + AND CASE + WHEN ws1.web_sales > 0 + THEN ws2.web_sales / ws1.web_sales + ELSE NULL + END > + CASE + WHEN ss1.store_sales > 0 + THEN ss2.store_sales / ss1.store_sales + ELSE NULL + END + AND CASE + WHEN ws2.web_sales > 0 + THEN ws3.web_sales / ws2.web_sales + ELSE NULL + END > + CASE + WHEN ss2.store_sales > 0 + THEN ss3.store_sales / ss2.store_sales + ELSE NULL + END +ORDER BY + web_q1_q2_increase +LIMIT 100;","selected_ss = addresses.store_sales.WHERE( + PRESENT(customer_address.county) + & (sold_date.year == 2000) +).CALCULATE( + ext_sales_price, + sold_quarter=sold_date.quarter_of_year +) + +selected_ws = addresses.web_sales_bill_addr.WHERE( + PRESENT(bill_address.county) + & (sold_date.year == 2000) +).CALCULATE( + ext_sales_price, + sold_quarter=sold_date.quarter_of_year +) +result = addresses.PARTITION(name='county_groups', by=(county)).CALCULATE( + ca_county=county, + d_year=2000, + store_sales_q1=SUM(selected_ss.WHERE(sold_quarter == 1).ext_sales_price), + store_sales_q2=SUM(selected_ss.WHERE(sold_quarter == 2).ext_sales_price), + store_sales_q3=SUM(selected_ss.WHERE(sold_quarter == 3).ext_sales_price), + web_sales_q1=SUM(selected_ws.WHERE(sold_quarter == 1).ext_sales_price), + web_sales_q2=SUM(selected_ws.WHERE(sold_quarter == 2).ext_sales_price), + web_sales_q3=SUM(selected_ws.WHERE(sold_quarter == 3).ext_sales_price) +).CALCULATE( + ca_county, + d_year, + web_q1_q2_increase=KEEP_IF(web_sales_q2 / web_sales_q1, web_sales_q1 != 0), + store_q1_q2_increase=KEEP_IF(store_sales_q2 / store_sales_q1, store_sales_q1 != 0), + web_q2_q3_increase=KEEP_IF(web_sales_q3 / web_sales_q2, web_sales_q2 != 0), + store_q2_q3_increase=KEEP_IF(store_sales_q3 / store_sales_q2, store_sales_q2 != 0) +).WHERE( + (web_q1_q2_increase > store_q1_q2_increase) + & (web_q2_q3_increase > store_q2_q3_increase) +).TOP_K(100, web_q1_q2_increase)","WITH _s4 AS ( + SELECT + ca_address_sk, + ca_county + FROM tpcds.customer_address +), _s0 AS ( + SELECT + ss_addr_sk, + ss_ext_sales_price, + ss_sold_date_sk + FROM tpcds.store_sales +), _t10 AS ( + SELECT + d_date_sk, + d_qoy, + d_year + FROM tpcds.date_dim + WHERE + d_qoy = 1 AND d_year = 2000 +), _s5 AS ( + SELECT + _s0.ss_addr_sk, + _s0.ss_ext_sales_price + FROM _s0 AS _s0 + LEFT JOIN _s4 AS _s1 + ON _s0.ss_addr_sk = _s1.ca_address_sk + JOIN _t10 AS _t10 + ON _s0.ss_sold_date_sk = _t10.d_date_sk + WHERE + NOT _s1.ca_county IS NULL +), _s10 AS ( + SELECT + _s4.ca_address_sk, + MAX(_s4.ca_county) AS anything_ca_county, + SUM(_s5.ss_ext_sales_price) AS sum_ss_ext_sales_price + FROM _s4 AS _s4 + LEFT JOIN _s5 AS _s5 + ON _s4.ca_address_sk = _s5.ss_addr_sk + GROUP BY + 1 +), _t12 AS ( + SELECT + d_date_sk, + d_qoy, + d_year + FROM tpcds.date_dim + WHERE + d_qoy = 2 AND d_year = 2000 +), _s11 AS ( + SELECT + _s6.ss_addr_sk, + _s6.ss_ext_sales_price + FROM _s0 AS _s6 + LEFT JOIN _s4 AS _s7 + ON _s6.ss_addr_sk = _s7.ca_address_sk + JOIN _t12 AS _t12 + ON _s6.ss_sold_date_sk = _t12.d_date_sk + WHERE + NOT _s7.ca_county IS NULL +), _s16 AS ( + SELECT + _s10.ca_address_sk, + MAX(_s10.anything_ca_county) AS anything_anything_ca_county, + MAX(_s10.sum_ss_ext_sales_price) AS anything_sum_ss_ext_sales_price, + SUM(_s11.ss_ext_sales_price) AS sum_ss_ext_sales_price + FROM _s10 AS _s10 + LEFT JOIN _s11 AS _s11 + ON _s10.ca_address_sk = _s11.ss_addr_sk + GROUP BY + 1 +), _t14 AS ( + SELECT + d_date_sk, + d_qoy, + d_year + FROM tpcds.date_dim + WHERE + d_qoy = 3 AND d_year = 2000 +), _s17 AS ( + SELECT + _s12.ss_addr_sk, + _s12.ss_ext_sales_price + FROM _s0 AS _s12 + LEFT JOIN _s4 AS _s13 + ON _s12.ss_addr_sk = _s13.ca_address_sk + JOIN _t14 AS _t14 + ON _s12.ss_sold_date_sk = _t14.d_date_sk + WHERE + NOT _s13.ca_county IS NULL +), _s22 AS ( + SELECT + _s16.ca_address_sk, + MAX(_s16.anything_anything_ca_county) AS anything_anything_anything_ca_county, + MAX(_s16.anything_sum_ss_ext_sales_price) AS anything_anything_sum_ss_ext_sales_price, + MAX(_s16.sum_ss_ext_sales_price) AS anything_sum_ss_ext_sales_price, + SUM(_s17.ss_ext_sales_price) AS sum_ss_ext_sales_price + FROM _s16 AS _s16 + LEFT JOIN _s17 AS _s17 + ON _s16.ca_address_sk = _s17.ss_addr_sk + GROUP BY + 1 +), _s18 AS ( + SELECT + ws_bill_addr_sk, + ws_ext_sales_price, + ws_sold_date_sk + FROM tpcds.web_sales +), _s23 AS ( + SELECT + _s18.ws_bill_addr_sk, + _s18.ws_ext_sales_price + FROM _s18 AS _s18 + LEFT JOIN _s4 AS _s19 + ON _s18.ws_bill_addr_sk = _s19.ca_address_sk + JOIN _t10 AS _t16 + ON _s18.ws_sold_date_sk = _t16.d_date_sk + WHERE + NOT _s19.ca_county IS NULL +), _s28 AS ( + SELECT + _s22.ca_address_sk, + MAX(_s22.anything_anything_anything_ca_county) AS anything_anything_anything_anything_ca_county, + MAX(_s22.anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s22.anything_sum_ss_ext_sales_price) AS anything_anything_sum_ss_ext_sales_price, + MAX(_s22.sum_ss_ext_sales_price) AS anything_sum_ss_ext_sales_price, + SUM(_s23.ws_ext_sales_price) AS sum_ws_ext_sales_price + FROM _s22 AS _s22 + LEFT JOIN _s23 AS _s23 + ON _s22.ca_address_sk = _s23.ws_bill_addr_sk + GROUP BY + 1 +), _s29 AS ( + SELECT + _s24.ws_bill_addr_sk, + _s24.ws_ext_sales_price + FROM _s18 AS _s24 + LEFT JOIN _s4 AS _s25 + ON _s24.ws_bill_addr_sk = _s25.ca_address_sk + JOIN _t12 AS _t18 + ON _s24.ws_sold_date_sk = _t18.d_date_sk + WHERE + NOT _s25.ca_county IS NULL +), _s34 AS ( + SELECT + _s28.ca_address_sk, + MAX(_s28.anything_anything_anything_anything_ca_county) AS anything_anything_anything_anything_anything_ca_county, + MAX(_s28.anything_anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s28.anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s28.anything_sum_ss_ext_sales_price) AS anything_anything_sum_ss_ext_sales_price, + MAX(_s28.sum_ws_ext_sales_price) AS anything_sum_ws_ext_sales_price, + SUM(_s29.ws_ext_sales_price) AS sum_ws_ext_sales_price + FROM _s28 AS _s28 + LEFT JOIN _s29 AS _s29 + ON _s28.ca_address_sk = _s29.ws_bill_addr_sk + GROUP BY + 1 +), _s35 AS ( + SELECT + _s30.ws_bill_addr_sk, + _s30.ws_ext_sales_price + FROM _s18 AS _s30 + LEFT JOIN _s4 AS _s31 + ON _s30.ws_bill_addr_sk = _s31.ca_address_sk + JOIN _t14 AS _t20 + ON _s30.ws_sold_date_sk = _t20.d_date_sk + WHERE + NOT _s31.ca_county IS NULL +), _t2 AS ( + SELECT + MAX(_s34.anything_anything_anything_anything_anything_ca_county) AS anything_anything_anything_anything_anything_anything_ca_county, + MAX(_s34.anything_anything_anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s34.anything_anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s34.anything_anything_sum_ss_ext_sales_price) AS anything_anything_anything_sum_ss_ext_sales_price, + MAX(_s34.anything_sum_ws_ext_sales_price) AS anything_anything_sum_ws_ext_sales_price, + MAX(_s34.sum_ws_ext_sales_price) AS anything_sum_ws_ext_sales_price, + SUM(_s35.ws_ext_sales_price) AS sum_ws_ext_sales_price + FROM _s34 AS _s34 + LEFT JOIN _s35 AS _s35 + ON _s34.ca_address_sk = _s35.ws_bill_addr_sk + GROUP BY + _s34.ca_address_sk +), _t1 AS ( + SELECT + anything_anything_anything_anything_anything_anything_ca_county, + SUM(anything_anything_anything_anything_anything_sum_ss_ext_sales_price) AS sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price, + SUM(anything_anything_anything_anything_sum_ss_ext_sales_price) AS sum_anything_anything_anything_anything_sum_ss_ext_sales_price, + SUM(anything_anything_anything_sum_ss_ext_sales_price) AS sum_anything_anything_anything_sum_ss_ext_sales_price, + SUM(anything_anything_sum_ws_ext_sales_price) AS sum_anything_anything_sum_ws_ext_sales_price, + SUM(anything_sum_ws_ext_sales_price) AS sum_anything_sum_ws_ext_sales_price, + SUM(sum_ws_ext_sales_price) AS sum_sum_ws_ext_sales_price + FROM _t2 + GROUP BY + 1 +) +SELECT + anything_anything_anything_anything_anything_anything_ca_county AS ca_county, + 2000 AS d_year, + CASE + WHEN sum_anything_anything_sum_ws_ext_sales_price <> 0 + THEN CAST(sum_anything_sum_ws_ext_sales_price AS DOUBLE PRECISION) / sum_anything_anything_sum_ws_ext_sales_price + ELSE NULL + END AS web_q1_q2_increase, + CASE + WHEN sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price <> 0 + THEN CAST(sum_anything_anything_anything_anything_sum_ss_ext_sales_price AS DOUBLE PRECISION) / sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price + ELSE NULL + END AS store_q1_q2_increase, + CASE + WHEN sum_anything_sum_ws_ext_sales_price <> 0 + THEN CAST(COALESCE(sum_sum_ws_ext_sales_price, 0) AS DOUBLE PRECISION) / sum_anything_sum_ws_ext_sales_price + ELSE NULL + END AS web_q2_q3_increase, + CASE + WHEN sum_anything_anything_anything_anything_sum_ss_ext_sales_price <> 0 + THEN CAST(COALESCE(sum_anything_anything_anything_sum_ss_ext_sales_price, 0) AS DOUBLE PRECISION) / sum_anything_anything_anything_anything_sum_ss_ext_sales_price + ELSE NULL + END AS store_q2_q3_increase +FROM _t1 +WHERE + CASE + WHEN ( + NOT sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price IS NULL + AND sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price <> 0 + ) + THEN CAST(COALESCE(sum_anything_anything_anything_anything_sum_ss_ext_sales_price, 0) AS DOUBLE PRECISION) / COALESCE(sum_anything_anything_anything_anything_anything_sum_ss_ext_sales_price, 0) + ELSE NULL + END < CASE + WHEN ( + NOT sum_anything_anything_sum_ws_ext_sales_price IS NULL + AND sum_anything_anything_sum_ws_ext_sales_price <> 0 + ) + THEN CAST(COALESCE(sum_anything_sum_ws_ext_sales_price, 0) AS DOUBLE PRECISION) / COALESCE(sum_anything_anything_sum_ws_ext_sales_price, 0) + ELSE NULL + END + AND CASE + WHEN ( + NOT sum_anything_anything_anything_anything_sum_ss_ext_sales_price IS NULL + AND sum_anything_anything_anything_anything_sum_ss_ext_sales_price <> 0 + ) + THEN CAST(COALESCE(sum_anything_anything_anything_sum_ss_ext_sales_price, 0) AS DOUBLE PRECISION) / COALESCE(sum_anything_anything_anything_anything_sum_ss_ext_sales_price, 0) + ELSE NULL + END < CASE + WHEN ( + NOT sum_anything_sum_ws_ext_sales_price IS NULL + AND sum_anything_sum_ws_ext_sales_price <> 0 + ) + THEN CAST(COALESCE(sum_sum_ws_ext_sales_price, 0) AS DOUBLE PRECISION) / COALESCE(sum_anything_sum_ws_ext_sales_price, 0) + ELSE NULL + END +ORDER BY + 3 NULLS FIRST +LIMIT 100",36.820881104000364,29.021674433000044,"Limit (cost=4382620.48..4382620.49 rows=1 width=214) (actual time=36489.538..36498.281 rows=100 loops=1) + CTE ss + -> Finalize GroupAggregate (cost=2471903.51..2871894.23 rows=1476800 width=62) (actual time=14365.747..14451.598 rows=38504 loops=1) + Group Key: ca.ca_county, d.d_qoy, d.d_year + -> Gather Merge (cost=2471903.51..2816514.23 rows=2953600 width=62) (actual time=14365.701..14402.657 rows=113517 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=2470903.48..2474595.48 rows=1476800 width=62) (actual time=14175.462..14182.346 rows=37839 loops=3) + Sort Key: ca.ca_county, d.d_qoy, d.d_year + Sort Method: external merge Disk: 4104kB + Worker 0: Sort Method: external merge Disk: 4112kB + Worker 1: Sort Method: external merge Disk: 4128kB + -> Partial HashAggregate (cost=2019162.03..2208520.47 rows=1476800 width=62) (actual time=13409.766..14109.851 rows=37839 loops=3) + Group Key: ca.ca_county, d.d_qoy, d.d_year + Planned Partitions: 64 Batches: 65 Memory Usage: 8209kB Disk Usage: 189464kB + Worker 0: Batches: 65 Memory Usage: 8209kB Disk Usage: 191520kB + Worker 1: Batches: 65 Memory Usage: 8209kB Disk Usage: 220168kB + -> Parallel Hash Join (cost=9830.58..1007443.28 rows=10937500 width=36) (actual time=284.551..10428.952 rows=8951984 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Hash Join (cost=6831.75..897130.92 rows=11460080 width=28) (actual time=276.553..8711.742 rows=9168133 loops=3) + Hash Cond: (ss.ss_addr_sk = ca.ca_address_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797545.22 rows=12000922 width=22) (actual time=0.012..5925.994 rows=9600330 loops=3) + -> Parallel Hash (cost=5529.67..5529.67 rows=104167 width=22) (actual time=276.238..276.239 rows=83333 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 16064kB + -> Parallel Seq Scan on customer_address ca (cost=0.00..5529.67 rows=104167 width=22) (actual time=183.086..192.954 rows=83333 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=7.319..7.320 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5056kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2461.70 rows=42970 width=24) (actual time=0.017..7.955 rows=73049 loops=1) + CTE ws + -> Finalize GroupAggregate (cost=836935.43..1289168.03 rows=1476800 width=62) (actual time=4893.170..6149.250 rows=37641 loops=1) + Group Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + -> Gather Merge (cost=836935.43..1233788.03 rows=2953600 width=62) (actual time=4893.105..6080.013 rows=102631 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=835935.40..891869.28 rows=1476800 width=62) (actual time=4654.112..5768.427 rows=34210 loops=3) + Group Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + -> Sort (cost=835935.40..843430.18 rows=2997910 width=36) (actual time=4654.061..5345.210 rows=2398318 loops=3) + Sort Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + Sort Method: external merge Disk: 96736kB + Worker 0: Sort Method: external merge Disk: 96216kB + Worker 1: Sort Method: external merge Disk: 159104kB + -> Parallel Hash Join (cost=9830.58..349473.35 rows=2997910 width=36) (actual time=312.238..1737.793 rows=2398318 loops=3) + Hash Cond: (ws.ws_sold_date_sk = d_1.d_date_sk) + -> Parallel Hash Join (cost=6831.75..317595.35 rows=2998510 width=28) (actual time=304.707..1295.704 rows=2398621 loops=3) + Hash Cond: (ws.ws_bill_addr_sk = ca_1.ca_address_sk) + -> Parallel Seq Scan on web_sales ws (cost=0.00..287023.10 rows=2999110 width=22) (actual time=0.204..366.466 rows=2399189 loops=3) + -> Parallel Hash (cost=5529.67..5529.67 rows=104167 width=22) (actual time=304.217..304.218 rows=83333 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 16064kB + -> Parallel Seq Scan on customer_address ca_1 (cost=0.00..5529.67 rows=104167 width=22) (actual time=201.611..211.577 rows=83333 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=6.798..6.799 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5056kB + -> Parallel Seq Scan on date_dim d_1 (cost=0.00..2461.70 rows=42970 width=24) (actual time=0.016..7.884 rows=73049 loops=1) + -> Sort (cost=221558.22..221558.23 rows=1 width=214) (actual time=35789.367..35789.377 rows=100 loops=1) + Sort Key: ((ws2.web_sales / ws1.web_sales)) + Sort Method: top-N heapsort Memory: 46kB + -> Nested Loop (cost=0.00..221558.21 rows=1 width=214) (actual time=20723.687..35788.958 rows=307 loops=1) + Join Filter: (((ss1.ca_county)::text = (ws3.ca_county)::text) AND (CASE WHEN (ws2.web_sales > '0'::numeric) THEN (ws3.web_sales / ws2.web_sales) ELSE NULL::numeric END > CASE WHEN (ss2.store_sales > '0'::numeric) THEN (ss3.store_sales / ss2.store_sales) ELSE NULL::numeric END)) + Rows Removed by Join Filter: 1717403 + -> Nested Loop (cost=0.00..184637.28 rows=1 width=558) (actual time=20643.844..34081.039 rows=930 loops=1) + Join Filter: (((ss1.ca_county)::text = (ws2.ca_county)::text) AND (CASE WHEN (ws1.web_sales > '0'::numeric) THEN (ws2.web_sales / ws1.web_sales) ELSE NULL::numeric END > CASE WHEN (ss1.store_sales > '0'::numeric) THEN (ss2.store_sales / ss1.store_sales) ELSE NULL::numeric END)) + Rows Removed by Join Filter: 3397560 + -> Nested Loop (cost=0.00..147716.35 rows=1 width=448) (actual time=19259.035..29401.471 rows=1842 loops=1) + Join Filter: ((ss1.ca_county)::text = (ws1.ca_county)::text) + Rows Removed by Join Filter: 3400336 + -> Nested Loop (cost=0.00..110795.89 rows=1 width=338) (actual time=14365.827..21267.536 rows=1846 loops=1) + Join Filter: ((ss1.ca_county)::text = (ss3.ca_county)::text) + Rows Removed by Join Filter: 3407716 + -> Nested Loop (cost=0.00..73870.43 rows=7 width=228) (actual time=14365.796..17779.558 rows=1846 loops=1) + Join Filter: ((ss1.ca_county)::text = (ss2.ca_county)::text) + Rows Removed by Join Filter: 3409563 + -> CTE Scan on ss ss1 (cost=0.00..36920.00 rows=37 width=118) (actual time=14365.763..14367.818 rows=1847 loops=1) + Filter: ((d_qoy = 1) AND (d_year = 2000)) + Rows Removed by Filter: 36657 + -> CTE Scan on ss ss2 (cost=0.00..36920.00 rows=37 width=110) (actual time=0.001..1.765 rows=1847 loops=1847) + Filter: ((d_year = 2000) AND (d_qoy = 2)) + Rows Removed by Filter: 36657 + -> CTE Scan on ss ss3 (cost=0.00..36920.00 rows=37 width=110) (actual time=0.001..1.808 rows=1847 loops=1846) + Filter: ((d_year = 2000) AND (d_qoy = 3)) + Rows Removed by Filter: 36657 + -> CTE Scan on ws ws1 (cost=0.00..36920.00 rows=37 width=110) (actual time=2.651..4.326 rows=1843 loops=1846) + Filter: ((d_qoy = 1) AND (d_year = 2000)) + Rows Removed by Filter: 35798 + -> CTE Scan on ws ws2 (cost=0.00..36920.00 rows=37 width=110) (actual time=0.001..2.446 rows=1845 loops=1842) + Filter: ((d_year = 2000) AND (d_qoy = 2)) + Rows Removed by Filter: 35796 + -> CTE Scan on ws ws3 (cost=0.00..36920.00 rows=37 width=110) (actual time=0.001..1.742 rows=1847 loops=930) + Filter: ((d_year = 2000) AND (d_qoy = 3)) + Rows Removed by Filter: 35794 +Planning Time: 1.286 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 12.185 ms, Inlining 374.869 ms, Optimization 948.722 ms, Emission 664.768 ms, Total 2000.544 ms +Execution Time: 36536.987 ms","Limit (cost=465644219238.26..465644219238.31 rows=22 width=68) (actual time=33306.287..33306.316 rows=100 loops=1) + CTE _s4 + -> Seq Scan on customer_address (cost=0.00..6988.00 rows=250000 width=22) (actual time=0.036..28.736 rows=250000 loops=1) + CTE _s0 + -> Seq Scan on store_sales (cost=0.00..965558.12 rows=28802212 width=22) (actual time=0.009..5188.242 rows=28800991 loops=1) + CTE _t10 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=92 width=24) (actual time=2.689..5.378 rows=91 loops=1) + Filter: ((d_qoy = 1) AND (d_year = 2000)) + Rows Removed by Filter: 72958 + CTE _t12 + -> Seq Scan on date_dim date_dim_1 (cost=0.00..3127.73 rows=90 width=24) (actual time=2.701..5.345 rows=91 loops=1) + Filter: ((d_qoy = 2) AND (d_year = 2000)) + Rows Removed by Filter: 72958 + CTE _t14 + -> Seq Scan on date_dim date_dim_2 (cost=0.00..3127.73 rows=92 width=24) (actual time=2.757..5.365 rows=92 loops=1) + Filter: ((d_qoy = 3) AND (d_year = 2000)) + Rows Removed by Filter: 72957 + CTE _s18 + -> Seq Scan on web_sales (cost=0.00..329010.64 rows=7197864 width=22) (actual time=0.036..1154.684 rows=7197566 loops=1) + -> Sort (cost=465642908298.29..465642908298.35 rows=22 width=68) (actual time=32025.545..32025.565 rows=100 loops=1) + Sort Key: (CASE WHEN (_t1.sum_anything_anything_sum_ws_ext_sales_price <> '0'::numeric) THEN ((_t1.sum_anything_sum_ws_ext_sales_price)::double precision / (_t1.sum_anything_anything_sum_ws_ext_sales_price)::double precision) ELSE NULL::double precision END) NULLS FIRST + Sort Method: top-N heapsort Memory: 46kB + -> Subquery Scan on _t1 (cost=465642908278.70..465642908297.80 rows=22 width=68) (actual time=31954.527..32025.464 rows=307 loops=1) + -> GroupAggregate (cost=465642908278.70..465642908296.70 rows=22 width=224) (actual time=31954.522..32025.131 rows=307 loops=1) + Group Key: _t2.anything_anything_anything_anything_anything_anything_ca_county + Filter: ((CASE WHEN ((sum(_t2.anything_anything_anything_anything_anything_sum_ss_ext_sales_p) IS NOT NULL) AND (sum(_t2.anything_anything_anything_anything_anything_sum_ss_ext_sales_p) <> '0'::numeric)) THEN ((COALESCE(sum(_t2.anything_anything_anything_anything_sum_ss_ext_sales_price), '0'::numeric))::double precision / (COALESCE(sum(_t2.anything_anything_anything_anything_anything_sum_ss_ext_sales_p), '0'::numeric))::double precision) ELSE NULL::double precision END < CASE WHEN ((sum(_t2.anything_anything_sum_ws_ext_sales_price) IS NOT NULL) AND (sum(_t2.anything_anything_sum_ws_ext_sales_price) <> '0'::numeric)) THEN ((COALESCE(sum(_t2.anything_sum_ws_ext_sales_price), '0'::numeric))::double precision / (COALESCE(sum(_t2.anything_anything_sum_ws_ext_sales_price), '0'::numeric))::double precision) ELSE NULL::double precision END) AND (CASE WHEN ((sum(_t2.anything_anything_anything_anything_sum_ss_ext_sales_price) IS NOT NULL) AND (sum(_t2.anything_anything_anything_anything_sum_ss_ext_sales_price) <> '0'::numeric)) THEN ((COALESCE(sum(_t2.anything_anything_anything_sum_ss_ext_sales_price), '0'::numeric))::double precision / (COALESCE(sum(_t2.anything_anything_anything_anything_sum_ss_ext_sales_price), '0'::numeric))::double precision) ELSE NULL::double precision END < CASE WHEN ((sum(_t2.anything_sum_ws_ext_sales_price) IS NOT NULL) AND (sum(_t2.anything_sum_ws_ext_sales_price) <> '0'::numeric)) THEN ((COALESCE(sum(_t2.sum_ws_ext_sales_price), '0'::numeric))::double precision / (COALESCE(sum(_t2.anything_sum_ws_ext_sales_price), '0'::numeric))::double precision) ELSE NULL::double precision END)) + Rows Removed by Filter: 1540 + -> Sort (cost=465642908278.70..465642908279.20 rows=200 width=224) (actual time=31953.884..31981.749 rows=250000 loops=1) + Sort Key: _t2.anything_anything_anything_anything_anything_anything_ca_county + Sort Method: external merge Disk: 8440kB + -> Subquery Scan on _t2 (cost=11037893.28..465642908271.06 rows=200 width=224) (actual time=27868.586..31761.556 rows=250000 loops=1) + -> GroupAggregate (cost=11037893.28..465642908269.06 rows=200 width=232) (actual time=27868.583..31737.873 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=11037893.28..465560546707.74 rows=4118077941 width=214) (actual time=27868.550..31522.203 rows=594015 loops=1) + Merge Cond: (_s4.ca_address_sk = _s30.ws_bill_addr_sk) + -> GroupAggregate (cost=10308764.47..465436265725.11 rows=200 width=200) (actual time=26786.099..30160.243 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=10308764.47..465365766018.72 rows=4028554508 width=182) (actual time=26786.052..29990.501 rows=436544 loops=1) + Merge Cond: (_s4.ca_address_sk = _s24.ws_bill_addr_sk) + -> GroupAggregate (cost=9591617.83..465244182891.27 rows=200 width=168) (actual time=25724.012..28749.634 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=9591617.83..465182411719.66 rows=4118077941 width=150) (actual time=25723.966..28587.620 rows=444366 loops=1) + Merge Cond: (_s4.ca_address_sk = _s18.ws_bill_addr_sk) + -> GroupAggregate (cost=8862489.02..465058130739.03 rows=200 width=136) (actual time=22415.425..25096.168 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=8862489.02..464852149917.28 rows=16478465540 width=118) (actual time=22415.384..24761.879 rows=1540400 loops=1) + Merge Cond: (_s4.ca_address_sk = _s12.ss_addr_sk) + -> GroupAggregate (cost=5904513.03..464354803599.32 rows=200 width=104) (actual time=18152.388..19641.180 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=5904513.03..464193601216.53 rows=16120238029 width=86) (actual time=18152.371..19427.052 rows=940049 loops=1) + Merge Cond: (_s4.ca_address_sk = _s6.ss_addr_sk) + -> GroupAggregate (cost=2997353.46..463707053276.82 rows=200 width=72) (actual time=14026.822..14801.866 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=2997353.46..309221438836.82 rows=20598081925000 width=100) (actual time=14026.795..14609.187 rows=982173 loops=1) + Merge Cond: (_s4.ca_address_sk = _s0.ss_addr_sk) + -> Sort (cost=39377.46..40002.46 rows=250000 width=86) (actual time=104.130..136.077 rows=250000 loops=1) + Sort Key: _s4.ca_address_sk + Sort Method: external merge Disk: 7976kB + -> CTE Scan on _s4 (cost=0.00..5000.00 rows=250000 width=86) (actual time=0.039..78.572 rows=250000 loops=1) + -> Materialize (cost=2957976.00..291365498.21 rows=16478465540 width=22) (actual time=13922.636..14353.177 rows=793573 loops=1) + -> Merge Join (cost=2957976.00..250169334.36 rows=16478465540 width=22) (actual time=13922.634..14228.356 rows=793573 loops=1) + Merge Cond: (_s1.ca_address_sk = _s0.ss_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=44.136..60.923 rows=242498 loops=1) + Sort Key: _s1.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s1 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.017..21.829 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2927280.60..2993525.69 rows=13249018 width=22) (actual time=13878.461..14061.950 rows=819009 loops=1) + -> Sort (cost=2927280.60..2960403.15 rows=13249018 width=22) (actual time=13878.459..13987.864 rows=819009 loops=1) + Sort Key: _s0.ss_addr_sk + Sort Method: external merge Disk: 21176kB + -> Hash Join (cost=2.99..816545.71 rows=13249018 width=22) (actual time=5.479..13718.020 rows=838762 loops=1) + Hash Cond: (_s0.ss_sold_date_sk = _t10.d_date_sk) + -> CTE Scan on _s0 (cost=0.00..576044.24 rows=28802212 width=30) (actual time=0.011..11652.832 rows=28800991 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=5.410..5.411 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t10 (cost=0.00..1.84 rows=92 width=8) (actual time=2.692..5.398 rows=91 loops=1) + -> Materialize (cost=2907159.57..285044963.85 rows=16120238029 width=22) (actual time=4125.542..4511.115 rows=748583 loops=1) + -> Merge Join (cost=2907159.57..244744368.77 rows=16120238029 width=22) (actual time=4125.540..4395.783 rows=748583 loops=1) + Merge Cond: (_s7.ca_address_sk = _s6.ss_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=45.351..62.871 rows=242495 loops=1) + Sort Key: _s7.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s7 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.230..23.132 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2876464.18..2941269.15 rows=12960995 width=22) (actual time=4080.150..4228.969 rows=772346 loops=1) + -> Sort (cost=2876464.18..2908866.66 rows=12960995 width=22) (actual time=4080.148..4158.521 rows=772346 loops=1) + Sort Key: _s6.ss_addr_sk + Sort Method: external merge Disk: 19968kB + -> Hash Join (cost=2.92..813665.41 rows=12960995 width=22) (actual time=5.586..3944.666 rows=791057 loops=1) + Hash Cond: (_s6.ss_sold_date_sk = _t12.d_date_sk) + -> CTE Scan on _s0 _s6 (cost=0.00..576044.24 rows=28802212 width=30) (actual time=0.186..2084.632 rows=28800991 loops=1) + -> Hash (cost=1.80..1.80 rows=90 width=8) (actual time=5.378..5.378 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t12 (cost=0.00..1.80 rows=90 width=8) (actual time=2.705..5.366 rows=91 loops=1) + -> Materialize (cost=2957976.00..291365498.21 rows=16478465540 width=22) (actual time=4262.989..4940.518 rows=1387452 loops=1) + -> Merge Join (cost=2957976.00..250169334.36 rows=16478465540 width=22) (actual time=4262.986..4724.279 rows=1387452 loops=1) + Merge Cond: (_s13.ca_address_sk = _s12.ss_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=45.742..61.549 rows=242498 loops=1) + Sort Key: _s13.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s13 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.007..22.595 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2927280.60..2993525.69 rows=13249018 width=22) (actual time=4217.203..4489.248 rows=1431272 loops=1) + -> Sort (cost=2927280.60..2960403.15 rows=13249018 width=22) (actual time=4217.200..4348.597 rows=1431272 loops=1) + Sort Key: _s12.ss_addr_sk + Sort Method: external merge Disk: 36944kB + -> Hash Join (cost=2.99..816545.71 rows=13249018 width=22) (actual time=5.422..3865.905 rows=1465854 loops=1) + Hash Cond: (_s12.ss_sold_date_sk = _t14.d_date_sk) + -> CTE Scan on _s0 _s12 (cost=0.00..576044.24 rows=28802212 width=30) (actual time=0.003..1990.881 rows=28800991 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=5.398..5.399 rows=92 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t14 (cost=0.00..1.84 rows=92 width=8) (actual time=2.760..5.385 rows=92 loops=1) + -> Materialize (cost=729128.81..72805005.87 rows=4118077941 width=22) (actual time=3308.533..3436.385 rows=211467 loops=1) + -> Merge Join (cost=729128.81..62509811.01 rows=4118077941 width=22) (actual time=3308.531..3402.904 rows=211467 loops=1) + Merge Cond: (_s19.ca_address_sk = _s18.ws_bill_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=44.990..59.894 rows=242494 loops=1) + Sort Key: _s19.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s19 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.008..21.590 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=698433.42..714988.50 rows=3311017 width=22) (actual time=3263.498..3304.578 rows=218521 loops=1) + -> Sort (cost=698433.42..706710.96 rows=3311017 width=22) (actual time=3263.496..3284.664 rows=218521 loops=1) + Sort Key: _s18.ws_bill_addr_sk + Sort Method: external merge Disk: 5632kB + -> Hash Join (cost=2.99..204062.43 rows=3311017 width=22) (actual time=0.165..3222.195 rows=218549 loops=1) + Hash Cond: (_s18.ws_sold_date_sk = _t16.d_date_sk) + -> CTE Scan on _s18 (cost=0.00..143957.28 rows=7197864 width=30) (actual time=0.037..2721.526 rows=7197566 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=0.022..0.023 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t10 _t16 (cost=0.00..1.84 rows=92 width=8) (actual time=0.003..0.010 rows=91 loops=1) + -> Materialize (cost=717146.64..71226195.60 rows=4028554508 width=22) (actual time=1062.032..1185.222 rows=202862 loops=1) + -> Merge Join (cost=717146.64..61154809.33 rows=4028554508 width=22) (actual time=1062.030..1153.803 rows=202862 loops=1) + Merge Cond: (_s25.ca_address_sk = _s24.ws_bill_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=45.545..60.422 rows=242489 loops=1) + Sort Key: _s25.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s25 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.008..21.802 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=686451.24..702646.44 rows=3239039 width=22) (actual time=1016.439..1055.971 rows=208375 loops=1) + -> Sort (cost=686451.24..694548.84 rows=3239039 width=22) (actual time=1016.437..1037.182 rows=208375 loops=1) + Sort Key: _s24.ws_bill_addr_sk + Sort Method: external merge Disk: 5368kB + -> Hash Join (cost=2.92..203342.58 rows=3239039 width=22) (actual time=0.122..979.340 rows=208401 loops=1) + Hash Cond: (_s24.ws_sold_date_sk = _t18.d_date_sk) + -> CTE Scan on _s18 _s24 (cost=0.00..143957.28 rows=7197864 width=30) (actual time=0.013..509.283 rows=7197566 loops=1) + -> Hash (cost=1.80..1.80 rows=90 width=8) (actual time=0.024..0.024 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t12 _t18 (cost=0.00..1.80 rows=90 width=8) (actual time=0.005..0.012 rows=91 loops=1) + -> Materialize (cost=729128.81..72805005.87 rows=4118077941 width=22) (actual time=1082.443..1285.970 rows=373250 loops=1) + -> Merge Join (cost=729128.81..62509811.01 rows=4118077941 width=22) (actual time=1082.442..1228.453 rows=373250 loops=1) + Merge Cond: (_s31.ca_address_sk = _s30.ws_bill_addr_sk) + -> Sort (cost=30695.39..31317.27 rows=248750 width=8) (actual time=45.064..60.407 rows=242491 loops=1) + Sort Key: _s31.ca_address_sk + Sort Method: external merge Disk: 2856kB + -> CTE Scan on _s4 _s31 (cost=0.00..5000.00 rows=248750 width=8) (actual time=0.008..21.499 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=698433.42..714988.50 rows=3311017 width=22) (actual time=1037.336..1110.829 rows=384796 loops=1) + -> Sort (cost=698433.42..706710.96 rows=3311017 width=22) (actual time=1037.334..1075.858 rows=384796 loops=1) + Sort Key: _s30.ws_bill_addr_sk + Sort Method: external merge Disk: 9912kB + -> Hash Join (cost=2.99..204062.43 rows=3311017 width=22) (actual time=0.040..967.470 rows=384834 loops=1) + Hash Cond: (_s30.ws_sold_date_sk = _t20.d_date_sk) + -> CTE Scan on _s18 _s30 (cost=0.00..143957.28 rows=7197864 width=30) (actual time=0.002..495.398 rows=7197566 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=0.023..0.023 rows=92 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t14 _t20 (cost=0.00..1.84 rows=92 width=8) (actual time=0.004..0.011 rows=92 loops=1) +Planning Time: 1.218 ms +JIT: + Functions: 197 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.116 ms, Inlining 14.128 ms, Optimization 717.730 ms, Emission 549.272 ms, Total 1287.246 ms +Execution Time: 33459.895 ms",SUCCESS