diff --git a/benchmark/benchmark_metrics.csv b/benchmark/benchmark_metrics.csv index 0fd61287c..971be85ef 100644 --- a/benchmark/benchmark_metrics.csv +++ b/benchmark/benchmark_metrics.csv @@ -5,3 +5,4 @@ run,total_questions,total_time_min,pyd_avg_time,pyd_min_time,pyd_max_time 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 20260924_R_v1.00.29,45,98.4,21.77,0.55,259.55 +20261005_R_v1.00.30,45,77.35,18.36,1.05,177.59 diff --git a/benchmark/comparisons/comparison_20261005_R_v1.00.30_vs_20260924_R_v1.00.29.csv b/benchmark/comparisons/comparison_20261005_R_v1.00.30_vs_20260924_R_v1.00.29.csv new file mode 100644 index 000000000..3a4921e9e --- /dev/null +++ b/benchmark/comparisons/comparison_20261005_R_v1.00.30_vs_20260924_R_v1.00.29.csv @@ -0,0 +1,46 @@ +index,benchmark,question_id,pydough_exec_time_previous,pydough_exec_time_current,improvement_pct,status +1,TPCH,Q1,25.12222703400016,13.191520846000005,47.491%,improved +2,TPCH,Q2,0.5537916010000572,1.050494469000114,-89.691%,regressed +3,TPCH,Q3,19.66307203099996,35.96806275199992,-82.922%,regressed +4,TPCH,Q4,27.3359989239998,24.52724948599985,10.275%,improved +5,TPCH,Q5,17.305836908999936,8.505322246999867,50.853%,improved +6,TPCH,Q6,8.746907042000203,2.1765993139999864,75.116%,improved +7,TPCH,Q7,26.09425751999993,10.98330791699982,57.909%,improved +8,TPCH,Q8,14.941022657999838,7.663431370999888,48.709%,improved +9,TPCH,Q9,25.49684381499992,12.02899629400008,52.822%,improved +10,TPCH,Q10,12.508475340000132,4.209320711999908,66.348%,improved +11,TPCH,Q11,5.108523949999835,2.8950720909999745,43.329%,improved +12,TPCH,Q12,9.087238805000196,2.031349158000012,77.646%,improved +13,TPCH,Q13,5.228130998999859,2.995057395999993,42.713%,improved +14,TPCH,Q14,10.433903339000151,3.7320269070000895,64.232%,improved +15,TPCH,Q15,11.241936476999854,3.127023931999929,72.184%,improved +16,TPCH,Q16,2.356271124000159,1.3323797150001155,43.454%,improved +17,TPCH,Q17,7.587404701999731,1.7561404140001289,76.855%,improved +18,TPCH,Q18,45.07150608200027,24.20113491899997,46.305%,improved +19,TPCH,Q19,7.684237410999685,2.312227637999968,69.909%,improved +20,TPCH,Q20,15.588055171999711,6.797240238999848,56.395%,improved +21,TPCH,Q21,259.5530814059998,177.5872717870002,31.58%,improved +22,TPCH,Q22,4.775585220000266,2.648717250000118,44.536%,improved +23,TPCDS,Q1,4.543726749000143,2.4787433420001435,45.447%,improved +24,TPCDS,Q2,23.069867285999862,18.630681193999862,19.242%,improved +25,TPCDS,Q3,19.757153520999964,16.69006664499966,15.524%,improved +26,TPCDS,Q6,14.2203845439999,13.93478659099992,2.008%,improved +27,TPCDS,Q7,14.42848396499994,14.18717597099976,1.672%,improved +28,TPCDS,Q8,14.772220625000044,14.082679052000003,4.668%,improved +29,TPCDS,Q9,67.06602830800057,66.90053598399982,0.247%,improved +30,TPCDS,Q10,30.202453959000195,29.618039413999668,1.935%,improved +31,TPCDS,Q11,46.6294989449998,35.01761257199996,24.902%,improved +32,TPCDS,Q12,2.9965063270001338,1.6675282300002436,44.351%,improved +33,TPCDS,Q13,14.53534120400036,14.071125608999864,3.194%,improved +34,TPCDS,Q15,10.86869061500056,10.415381953999711,4.171%,improved +35,TPCDS,Q18,14.616575766999633,11.323835354999574,22.527%,improved +36,TPCDS,Q19,14.756610225999792,14.150067407999812,4.11%,improved +37,TPCDS,Q20,20.81944694499998,19.049852600999657,8.5%,improved +38,TPCDS,Q21,19.9502591950004,19.567928284999653,1.916%,improved +39,TPCDS,Q22,22.04286588800005,20.755374403000133,5.841%,improved +40,TPCDS,Q26,2.029492419999769,9.980045934999907,-391.751%,regressed +41,TPCDS,Q27,3.3871888630001195,14.051356692000809,-314.838%,regressed +42,TPCDS,Q28,12.755850775,80.18928681299985,-528.647%,regressed +43,TPCDS,Q29,14.954332538999552,23.93200026399973,-60.034%,regressed +44,TPCDS,Q30,4.683692449999398,2.4294510019999507,48.13%,improved +45,TPCDS,Q31,25.04836453899952,21.275582393999684,15.062%,improved diff --git a/benchmark/metrics/20261005_R_v1.00.30.csv b/benchmark/metrics/20261005_R_v1.00.30.csv new file mode 100644 index 000000000..11730236b --- /dev/null +++ b/benchmark/metrics/20261005_R_v1.00.30.csv @@ -0,0 +1,9802 @@ +,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",12.956251751999957,13.191520846000003,"Finalize GroupAggregate (cost=1685201.13..1698235.12 rows=40000 width=248) (actual time=13183.456..13188.292 rows=4 loops=1) + Group Key: l_returnflag, l_linestatus + -> Gather Merge (cost=1685201.13..1694535.12 rows=80000 width=248) (actual time=13183.428..13188.250 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1684201.11..1684301.11 rows=40000 width=248) (actual time=13174.116..13174.118 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=13174.081..13174.094 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=124.322..2241.524 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.135 ms +JIT: + Functions: 27 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.882 ms, Inlining 92.110 ms, Optimization 159.587 ms, Emission 121.297 ms, Total 374.877 ms +Execution Time: 13189.064 ms","Finalize GroupAggregate (cost=1700456.10..1714290.08 rows=40000 width=248) (actual time=15303.670..15308.762 rows=4 loops=1) + Group Key: l_returnflag, l_linestatus + -> Gather Merge (cost=1700456.10..1709790.08 rows=80000 width=248) (actual time=15303.639..15308.714 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1699456.07..1699556.07 rows=40000 width=248) (actual time=15291.450..15291.452 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=15291.415..15291.428 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=122.779..3347.012 rows=19714203 loops=3) + Filter: (l_shipdate <= '1998-09-02'::date) + Rows Removed by Filter: 281148 +Planning Time: 0.134 ms +JIT: + Functions: 27 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.063 ms, Inlining 88.799 ms, Optimization 156.588 ms, Emission 122.565 ms, Total 370.015 ms +Execution Time: 15309.670 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",118.85072799700004,1.050494469000114,"Limit (cost=383438.69..383438.69 rows=1 width=592) (actual time=148741.208..148742.266 rows=10 loops=1) + -> Sort (cost=383438.69..383438.69 rows=1 width=592) (actual time=148729.150..148730.206 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=202724.75..383438.68 rows=1 width=592) (actual time=4958.954..148727.595 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..178842.30 rows=1 width=72) (actual time=98.249..100.837 rows=7854 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Index Scan using part_pkey on part p (cost=0.42..177842.16 rows=1 width=72) (actual time=2.576..902.447 rows=2618 loops=3) + Filter: (((p_type)::text ~~ '%BRASS'::text) AND (p_size = 15)) + Rows Removed by Filter: 664049 + -> Materialize (cost=201724.30..201798.70 rows=14881 width=542) (actual time=4795.937..5257.468 rows=1602443 loops=1) + -> Sort (cost=201724.30..201761.50 rows=14881 width=542) (actual time=4795.931..5160.476 rows=1602443 loops=1) + Sort Key: ps.ps_partkey + Sort Method: external merge Disk: 253032kB + -> Gather (cost=3439.51..197080.96 rows=14881 width=542) (actual time=30.831..4395.936 rows=1602640 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2439.51..194592.86 rows=6200 width=542) (actual time=17.495..4410.519 rows=534213 loops=3) + Hash Cond: (ps.ps_suppkey = s.s_suppkey) + -> Parallel Seq Scan on partsupp ps (cost=0.00..187466.51 rows=1240051 width=26) (actual time=0.222..4142.328 rows=2666667 loops=3) + -> Parallel Hash (cost=2438.25..2438.25 rows=101 width=524) (actual time=16.278..16.282 rows=6678 loops=3) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 4120kB + -> Hash Join (cost=24.81..2438.25 rows=101 width=524) (actual time=6.413..12.009 rows=6678 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Parallel Seq Scan on supplier s (cost=0.00..2337.04 rows=20104 width=460) (actual time=0.010..2.844 rows=33333 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=6.389..6.392 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=6.383..6.388 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.067..0.068 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=6.298..6.299 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=6.291..6.292 rows=1 loops=3) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 4 + SubPlan 1 + -> Aggregate (cost=2760.45..2760.46 rows=1 width=32) (actual time=22.563..22.563 rows=1 loops=6351) + -> Nested Loop (cost=25.24..2760.26 rows=74 width=18) (actual time=9.394..22.562 rows=2 loops=6351) + -> Hash Join (cost=24.81..2632.44 rows=171 width=4) (actual time=0.001..9.659 rows=20033 loops=6351) + Hash Cond: (s2.s_nationkey = n2.n_nationkey) + -> Seq Scan on supplier s2 (cost=0.00..2477.76 rows=34176 width=8) (actual time=0.000..4.045 rows=100000 loops=6351) + -> Hash (cost=24.80..24.80 rows=1 width=4) (actual time=0.031..0.033 rows=5 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=4) (actual time=0.026..0.030 rows=5 loops=1) + Hash Cond: (n2.n_regionkey = r2.r_regionkey) + -> Seq Scan on nation n2 (cost=0.00..11.90 rows=190 width=8) (actual time=0.003..0.004 rows=25 loops=1) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.013..0.014 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on region r2 (cost=0.00..12.38 rows=1 width=4) (actual time=0.008..0.008 rows=1 loops=1) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 4 + -> Index Scan using partsupp_pkey on partsupp ps2 (cost=0.43..23.92 rows=74 width=22) (actual time=0.001..0.001 rows=0 loops=127229583) + Index Cond: ((ps_partkey = p.p_partkey) AND (ps_suppkey = s2.s_suppkey)) +Planning Time: 0.485 ms +JIT: + Functions: 139 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 5.594 ms, Inlining 0.000 ms, Optimization 1.951 ms, Emission 33.726 ms, Total 41.270 ms +Execution Time: 148748.769 ms","Limit (cost=87915.82..87915.83 rows=1 width=592) (actual time=168.007..170.642 rows=10 loops=1) + -> Sort (cost=87915.82..87915.83 rows=1 width=592) (actual time=168.005..170.640 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=87915.78..87915.81 rows=1 width=592) (actual time=164.190..169.736 rows=4667 loops=1) + Filter: (_t._w = 1) + -> WindowAgg (cost=87915.78..87915.80 rows=1 width=622) (actual time=164.189..169.398 rows=4667 loops=1) + Run Condition: (rank() OVER (?) <= 1) + -> Sort (cost=87915.78..87915.78 rows=1 width=614) (actual time=164.179..167.044 rows=6351 loops=1) + Sort Key: partsupp.ps_partkey, partsupp.ps_supplycost + Sort Method: quicksort Memory: 1438kB + -> Gather (cost=1560.35..87915.77 rows=1 width=614) (actual time=0.506..165.148 rows=6351 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Nested Loop (cost=560.35..86915.67 rows=1 width=614) (actual time=0.209..154.443 rows=2117 loops=3) + -> Nested Loop (cost=560.19..86914.79 rows=2 width=618) (actual time=0.102..152.389 rows=10472 loops=3) + -> Nested Loop (cost=560.05..86914.46 rows=2 width=550) (actual time=0.096..146.035 rows=10472 loops=3) + -> Nested Loop (cost=559.76..86913.84 rows=2 width=98) (actual time=0.081..129.895 rows=10472 loops=3) + -> Parallel Seq Scan on part (cost=0.00..41148.07 rows=1 width=72) (actual time=0.056..71.455 rows=2618 loops=3) + Filter: (((p_type)::text ~~ '%BRASS'::text) AND (p_size = 15)) + Rows Removed by Filter: 664049 + -> Bitmap Heap Scan on partsupp (cost=559.76..45616.95 rows=14881 width=26) (actual time=0.020..0.021 rows=4 loops=7854) + Recheck Cond: (part.p_partkey = ps_partkey) + Heap Blocks: exact=2977 + -> Bitmap Index Scan on partsupp_pkey (cost=0.00..556.04 rows=14881 width=0) (actual time=0.006..0.006 rows=4 loops=7854) + Index Cond: (ps_partkey = part.p_partkey) + -> Index Scan using supplier_pkey on supplier (cost=0.29..0.31 rows=1 width=460) (actual time=0.001..0.001 rows=1 loops=31416) + Index Cond: (s_suppkey = partsupp.ps_suppkey) + -> Index Scan using nation_pkey on nation (cost=0.14..0.16 rows=1 width=76) (actual time=0.000..0.000 rows=1 loops=31416) + Index Cond: (n_nationkey = supplier.s_nationkey) + -> Memoize (cost=0.15..0.43 rows=1 width=4) (actual time=0.000..0.000 rows=0 loops=31416) + Cache Key: nation.n_regionkey + Cache Mode: logical + Hits: 11139 Misses: 5 Evictions: 0 Overflows: 0 Memory Usage: 1kB + Worker 0: Hits: 10311 Misses: 5 Evictions: 0 Overflows: 0 Memory Usage: 1kB + Worker 1: Hits: 9951 Misses: 5 Evictions: 0 Overflows: 0 Memory Usage: 1kB + -> Index Scan using region_pkey on region (cost=0.14..0.42 rows=1 width=4) (actual time=0.002..0.002 rows=0 loops=15) + Index Cond: (r_regionkey = nation.n_regionkey) + Filter: ((r_name)::text = 'EUROPE'::text) + Rows Removed by Filter: 1 +Planning Time: 0.337 ms +Execution Time: 170.685 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",45.831071157999986,35.96806275199992,"Limit (cost=1435715.99..1435716.01 rows=10 width=44) (actual time=34020.343..34254.549 rows=10 loops=1) + -> Sort (cost=1435715.99..1435746.10 rows=12044 width=44) (actual time=33894.476..34128.680 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=1433870.78..1435455.72 rows=12044 width=44) (actual time=33792.790..34115.302 rows=114003 loops=1) + Group Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + -> Gather Merge (cost=1433870.78..1435179.72 rows=10036 width=44) (actual time=33792.774..34074.778 rows=114033 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1432870.75..1433021.29 rows=5018 width=44) (actual time=33778.344..33814.873 rows=38011 loops=3) + Group Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + -> Sort (cost=1432870.75..1432883.30 rows=5018 width=48) (actual time=33778.298..33784.088 rows=100705 loops=3) + Sort Key: l.l_orderkey, o.o_orderdate, o.o_shippriority + Sort Method: external merge Disk: 3576kB + Worker 0: Sort Method: external merge Disk: 3360kB + Worker 1: Sort Method: external merge Disk: 3584kB + -> Parallel Hash Join (cost=322921.94..1432562.32 rows=5018 width=48) (actual time=27851.712..33752.368 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.142..20392.534 rows=10778083 loops=3) + Filter: (l_shipdate > '1995-03-15'::date) + Rows Removed by Filter: 9217267 + -> Parallel Hash (cost=322871.59..322871.59 rows=4028 width=12) (actual time=5045.699..5045.703 rows=487308 loops=3) + Buckets: 131072 (originally 16384) Batches: 16 (originally 1) Memory Usage: 5376kB + -> Parallel Hash Join (cost=38363.36..322871.59 rows=4028 width=12) (actual time=692.849..4949.094 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.042..3965.998 rows=2429814 loops=3) + Filter: (o_orderdate < '1995-03-15'::date) + Rows Removed by Filter: 2570186 + -> Parallel Hash (cost=38350.33..38350.33 rows=1042 width=4) (actual time=692.771..692.772 rows=100092 loops=3) + Buckets: 524288 (originally 4096) Batches: 1 (originally 1) Memory Usage: 19968kB + -> Parallel Seq Scan on customer c (cost=0.00..38350.33 rows=1042 width=4) (actual time=107.553..622.185 rows=100092 loops=3) + Filter: ((c_mktsegment)::text = 'BUILDING'::text) + Rows Removed by Filter: 399908 +Planning Time: 0.284 ms +JIT: + Functions: 94 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.232 ms, Inlining 99.370 ms, Optimization 201.568 ms, Emission 142.116 ms, Total 446.286 ms +Execution Time: 34256.234 ms","Limit (cost=1541799.28..1541799.30 rows=10 width=44) (actual time=32872.181..33028.499 rows=10 loops=1) + -> Sort (cost=1541799.28..1543015.72 rows=486577 width=44) (actual time=32745.464..32901.782 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=1467249.16..1531284.52 rows=486577 width=44) (actual time=32639.971..32888.289 rows=114003 loops=1) + Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority + -> Gather Merge (cost=1467249.16..1520133.81 rows=405480 width=44) (actual time=32639.948..32847.227 rows=114029 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1466249.14..1472331.34 rows=202740 width=44) (actual time=32626.591..32664.285 rows=38010 loops=3) + Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority + -> Sort (cost=1466249.14..1466755.99 rows=202740 width=48) (actual time=32626.551..32632.817 rows=100705 loops=3) + Sort Key: lineitem.l_orderkey NULLS FIRST, orders.o_orderdate NULLS FIRST, orders.o_shippriority + Sort Method: external merge Disk: 3800kB + Worker 0: Sort Method: external merge Disk: 3240kB + Worker 1: Sort Method: external merge Disk: 3488kB + -> Parallel Hash Join (cost=331677.12..1442141.34 rows=202740 width=48) (actual time=21460.215..32602.911 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.150..14224.842 rows=10778083 loops=3) + Filter: (l_shipdate > '1995-03-15'::date) + Rows Removed by Filter: 9217267 + -> Parallel Hash (cost=329643.01..329643.01 rows=162729 width=12) (actual time=3971.051..3971.055 rows=487308 loops=3) + Buckets: 131072 (originally 524288) Batches: 16 (originally 1) Memory Usage: 5376kB + -> Parallel Hash Join (cost=45134.79..329643.01 rows=162729 width=12) (actual time=380.895..3874.478 rows=487308 loops=3) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Parallel Seq Scan on orders (cost=0.00..282393.54 rows=805588 width=16) (actual time=0.037..3210.128 rows=2429814 loops=3) + Filter: (o_orderdate < '1995-03-15'::date) + Rows Removed by Filter: 2570186 + -> Parallel Hash (cost=43556.64..43556.64 rows=126252 width=4) (actual time=379.998..379.999 rows=100092 loops=3) + Buckets: 524288 Batches: 1 Memory Usage: 15872kB + -> Parallel Seq Scan on customer (cost=0.00..43556.64 rows=126252 width=4) (actual time=107.945..362.356 rows=100092 loops=3) + Filter: ((c_mktsegment)::text = 'BUILDING'::text) + Rows Removed by Filter: 399908 +Planning Time: 0.313 ms +JIT: + Functions: 94 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.954 ms, Inlining 83.268 ms, Optimization 216.014 ms, Emission 151.013 ms, Total 453.249 ms +Execution Time: 33030.361 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",99.0195396680001,24.527249485999846,"GroupAggregate (cost=1277167.58..1277278.33 rows=200 width=56) (actual time=77174.306..77206.959 rows=5 loops=1) + Group Key: o.o_orderpriority + -> Sort (cost=1277167.58..1277203.83 rows=14500 width=48) (actual time=77166.076..77190.319 rows=526040 loops=1) + Sort Key: o.o_orderpriority + Sort Method: external merge Disk: 6920kB + -> Nested Loop (cost=1274471.79..1276165.36 rows=14500 width=48) (actual time=11865.482..77099.629 rows=526040 loops=1) + -> HashAggregate (cost=1274471.36..1274473.36 rows=200 width=4) (actual time=11862.358..21888.130 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=57.295..6326.200 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=52) (actual time=0.004..0.004 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.213 ms +JIT: + Functions: 20 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 0.776 ms, Inlining 7.393 ms, Optimization 30.321 ms, Emission 22.880 ms, Total 61.369 ms +Execution Time: 77344.086 ms","GroupAggregate (cost=1108569.21..1108569.23 rows=1 width=17) (actual time=27660.049..27711.790 rows=5 loops=1) + Group Key: orders.o_orderpriority + -> Sort (cost=1108569.21..1108569.21 rows=1 width=9) (actual time=27651.915..27695.359 rows=526040 loops=1) + Sort Key: orders.o_orderpriority NULLS FIRST + Sort Method: external merge Disk: 6912kB + -> Nested Loop (cost=1106828.20..1108569.20 rows=1 width=9) (actual time=12932.090..27616.939 rows=526040 loops=1) + -> Group (cost=1106827.76..1106875.43 rows=200 width=4) (actual time=12854.596..14813.025 rows=13753474 loops=1) + Group Key: lineitem.l_orderkey + -> Gather Merge (cost=1106827.76..1106874.43 rows=400 width=4) (actual time=12854.564..14055.356 rows=13759149 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1105827.74..1105828.24 rows=200 width=4) (actual time=12482.331..12711.048 rows=4586383 loops=3) + Sort Key: lineitem.l_orderkey + Sort Method: external merge Disk: 55688kB + Worker 0: Sort Method: external merge Disk: 56848kB + Worker 1: Sort Method: external merge Disk: 49328kB + -> Partial HashAggregate (cost=1105818.09..1105820.09 rows=200 width=4) (actual time=7361.696..11741.425 rows=4586383 loops=3) + Group Key: lineitem.l_orderkey + Batches: 277 Memory Usage: 10305kB Disk Usage: 411744kB + Worker 0: Batches: 229 Memory Usage: 10561kB Disk Usage: 419968kB + Worker 1: Batches: 277 Memory Usage: 10305kB Disk Usage: 365288kB + -> Parallel Seq Scan on lineitem (cost=0.00..1098328.25 rows=2995938 width=4) (actual time=71.571..4909.473 rows=12643116 loops=3) + Filter: ((l_orderkey IS NOT NULL) AND (l_commitdate < l_receiptdate)) + Rows Removed by Filter: 7352235 + -> Index Scan using orders_pkey on orders (cost=0.43..8.47 rows=1 width=13) (actual time=0.001..0.001 rows=0 loops=13753474) + Index Cond: (o_orderkey = lineitem.l_orderkey) + 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: 1 +Planning Time: 0.227 ms +JIT: + Functions: 40 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.254 ms, Inlining 86.631 ms, Optimization 76.702 ms, Emission 61.726 ms, Total 228.313 ms +Execution Time: 27763.740 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",11.0625397660001,8.505322246999867,"Sort (cost=1402423.24..1402423.71 rows=190 width=100) (actual time=10357.170..10365.731 rows=5 loops=1) + Sort Key: (sum((l.l_extendedprice * ('1'::numeric - l.l_discount)))) DESC + Sort Method: quicksort Memory: 25kB + -> Finalize GroupAggregate (cost=1402360.96..1402416.05 rows=190 width=100) (actual time=10354.223..10365.722 rows=5 loops=1) + Group Key: n.n_name + -> Gather Merge (cost=1402360.96..1402410.82 rows=380 width=100) (actual time=10353.187..10365.699 rows=15 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1401360.94..1401366.94 rows=190 width=100) (actual time=10334.214..10338.446 rows=5 loops=3) + Group Key: n.n_name + -> Sort (cost=1401360.94..1401361.66 rows=290 width=104) (actual time=10333.122..10333.948 rows=24328 loops=3) + Sort Key: n.n_name + Sort Method: quicksort Memory: 2152kB + Worker 0: Sort Method: quicksort Memory: 1790kB + Worker 1: Sort Method: quicksort Memory: 1778kB + -> Nested Loop (cost=2977.46..1401349.08 rows=290 width=104) (actual time=313.193..10326.019 rows=24328 loops=3) + Join Filter: (c.c_nationkey = s.s_nationkey) + Rows Removed by Join Filter: 584019 + -> Nested Loop (cost=2977.03..1363760.79 rows=7248 width=116) (actual time=312.937..8583.688 rows=608347 loops=3) + -> Parallel Hash Join (cost=2976.60..1112875.19 rows=47542 width=116) (actual time=312.633..4150.071 rows=4007022 loops=3) + Hash Cond: (l.l_suppkey = s.s_suppkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1075745.80 rows=9032980 width=44) (actual time=0.183..1940.075 rows=19995351 loops=3) + -> Parallel Hash (cost=2972.74..2972.74 rows=309 width=80) (actual time=312.269..312.274 rows=6679 loops=3) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1656kB + -> Hash Join (cost=24.81..2972.74 rows=309 width=80) (actual time=239.068..271.981 rows=6679 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.110..30.931 rows=33333 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=238.943..238.946 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=238.937..238.942 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.070..0.072 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=238.851..238.851 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=238.839..238.840 rows=1 loops=3) + Filter: ((r_name)::text = 'ASIA'::text) + Rows Removed by Filter: 4 + -> Index Scan using orders_pkey on orders o (cost=0.43..5.28 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=12021065) + Index Cond: (o_orderkey = l.l_orderkey) + Filter: ((o_orderdate >= '1994-01-01'::date) AND (o_orderdate < '1995-01-01 00:00:00'::timestamp without time zone)) + Rows Removed by Filter: 1 + -> Index Scan using customer_pkey on customer c (cost=0.43..5.17 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=1825042) + Index Cond: (c_custkey = o.o_custkey) +Planning Time: 1.084 ms +JIT: + Functions: 147 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.000 ms, Inlining 104.522 ms, Optimization 376.961 ms, Emission 234.961 ms, Total 722.444 ms +Execution Time: 10367.109 ms","Sort (cost=1402205.53..1402205.76 rows=92 width=68) (actual time=9533.672..9539.742 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=1402190.80..1402202.52 rows=92 width=68) (actual time=9530.104..9539.734 rows=5 loops=1) + Group Key: nation.n_nationkey + -> Gather Merge (cost=1402190.80..1402200.61 rows=76 width=68) (actual time=9528.519..9539.705 rows=15 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1401190.77..1401191.82 rows=38 width=68) (actual time=9513.763..9518.189 rows=5 loops=3) + Group Key: nation.n_nationkey + -> Sort (cost=1401190.77..1401190.87 rows=38 width=108) (actual time=9512.175..9513.645 rows=24328 loops=3) + Sort Key: nation.n_nationkey + Sort Method: quicksort Memory: 1834kB + Worker 0: Sort Method: quicksort Memory: 1976kB + Worker 1: Sort Method: quicksort Memory: 2112kB + -> Nested Loop (cost=2990.10..1401189.78 rows=38 width=108) (actual time=330.200..9506.364 rows=24328 loops=3) + Join Filter: (nation.n_nationkey = customer.c_nationkey) + Rows Removed by Join Filter: 584019 + -> Nested Loop (cost=2989.67..1363620.39 rows=7243 width=112) (actual time=330.097..7852.521 rows=608347 loops=3) + -> Parallel Hash Join (cost=2989.23..1112887.83 rows=47513 width=112) (actual time=330.041..3539.768 rows=4007022 loops=3) + Hash Cond: (lineitem.l_suppkey = supplier.s_suppkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1075745.80 rows=9032980 width=44) (actual time=0.014..1315.783 rows=19995351 loops=3) + -> Parallel Hash (cost=2985.37..2985.37 rows=309 width=76) (actual time=329.897..329.904 rows=6679 loops=3) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1528kB + -> Hash Join (cost=37.44..2985.37 rows=309 width=76) (actual time=284.739..290.729 rows=6679 loops=3) + Hash Cond: (supplier.s_nationkey = nation_1.n_nationkey) + -> Parallel Seq Scan on supplier (cost=0.00..2724.24 rows=58824 width=8) (actual time=0.015..3.935 rows=33333 loops=3) + -> Hash (cost=37.43..37.43 rows=1 width=76) (actual time=284.710..284.715 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=24.81..37.43 rows=1 width=76) (actual time=284.703..284.711 rows=5 loops=3) + Hash Cond: ((nation_1.n_name)::text = (nation.n_name)::text) + -> Seq Scan on nation nation_1 (cost=0.00..11.90 rows=190 width=72) (actual time=0.007..0.009 rows=25 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=72) (actual time=284.670..284.673 rows=5 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Hash Join (cost=12.39..24.80 rows=1 width=72) (actual time=284.664..284.668 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.001..0.004 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=284.641..284.642 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=284.629..284.631 rows=1 loops=3) + Filter: ((r_name)::text = 'ASIA'::text) + Rows Removed by Filter: 4 + -> Index Scan using orders_pkey on orders (cost=0.43..5.28 rows=1 width=8) (actual time=0.001..0.001 rows=0 loops=12021065) + Index Cond: (o_orderkey = lineitem.l_orderkey) + Filter: ((o_orderdate < '1995-01-01'::date) AND (o_orderdate >= '1994-01-01'::date)) + Rows Removed by Filter: 1 + -> Index Scan using customer_pkey on customer (cost=0.43..5.17 rows=1 width=8) (actual time=0.002..0.003 rows=1 loops=1825042) + Index Cond: (c_custkey = orders.o_custkey) +Planning Time: 0.890 ms +JIT: + Functions: 174 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.275 ms, Inlining 103.713 ms, Optimization 468.582 ms, Emission 281.719 ms, Total 858.289 ms +Execution Time: 9541.308 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)",1.5378209959999367,2.1765993139999864,"Finalize Aggregate (cost=1189658.65..1189658.66 rows=1 width=32) (actual time=1492.788..1498.828 rows=1 loops=1) + -> Gather (cost=1189658.43..1189658.64 rows=2 width=32) (actual time=1492.638..1498.817 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1188658.43..1188658.44 rows=1 width=32) (actual time=1480.591..1480.592 rows=1 loops=3) + -> Parallel Seq Scan on lineitem l (cost=0.00..1188658.05 rows=75 width=36) (actual time=72.973..1423.802 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.082 ms +JIT: + Functions: 17 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.302 ms, Inlining 99.441 ms, Optimization 70.639 ms, Emission 48.819 ms, Total 220.201 ms +Execution Time: 1499.382 ms","Finalize Aggregate (cost=1189658.65..1189658.66 rows=1 width=32) (actual time=2225.080..2231.304 rows=1 loops=1) + -> Gather (cost=1189658.43..1189658.64 rows=2 width=32) (actual time=2224.924..2231.277 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1188658.43..1188658.44 rows=1 width=32) (actual time=2212.794..2212.795 rows=1 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1188658.05 rows=75 width=36) (actual time=70.728..2154.533 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.080 ms +JIT: + Functions: 17 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.355 ms, Inlining 96.170 ms, Optimization 68.076 ms, Emission 47.899 ms, Total 213.499 ms +Execution Time: 2231.892 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",4.0944614140000795,10.98330791699982,"Finalize GroupAggregate (cost=1130447.81..1130448.48 rows=6 width=200) (actual time=4458.657..4470.292 rows=4 loops=1) + Group Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + -> Gather Merge (cost=1130447.81..1130448.34 rows=4 width=200) (actual time=4457.495..4470.272 rows=12 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1129447.79..1129447.85 rows=2 width=200) (actual time=4439.246..4443.063 rows=4 loops=3) + Group Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + -> Sort (cost=1129447.79..1129447.79 rows=2 width=204) (actual time=4437.971..4438.646 rows=19455 loops=3) + Sort Key: n1.n_name, n2.n_name, (EXTRACT(year FROM l.l_shipdate)) + Sort Method: quicksort Memory: 2195kB + Worker 0: Sort Method: quicksort Memory: 1831kB + Worker 1: Sort Method: quicksort Memory: 1815kB + -> Hash Join (cost=2916.45..1129447.78 rows=2 width=204) (actual time=251.771..4429.982 rows=19455 loops=3) + Hash Cond: (c.c_nationkey = n2.n_nationkey) + 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 + -> Nested Loop (cost=2903.57..1129433.65 rows=475 width=112) (actual time=4.470..4140.140 rows=486752 loops=3) + -> Nested Loop (cost=2903.14..1126979.19 rows=475 width=112) (actual time=4.415..2616.342 rows=486752 loops=3) + -> Parallel Hash Join (cost=2902.71..1123985.58 rows=475 width=112) (actual time=4.353..1910.534 rows=486752 loops=3) + Hash Cond: (l.l_suppkey = s.s_suppkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1120910.70 rows=45165 width=48) (actual time=0.034..1410.104 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=2894.97..2894.97 rows=619 width=72) (actual time=4.175..4.177 rows=2670 loops=3) + Buckets: 8192 (originally 2048) Batches: 1 (originally 1) Memory Usage: 496kB + -> Hash Join (cost=12.88..2894.97 rows=619 width=72) (actual time=0.030..11.615 rows=8010 loops=1) + 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.007..7.319 rows=100000 loops=1) + -> Hash (cost=12.85..12.85 rows=2 width=72) (actual time=0.012..0.013 rows=2 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n1 (cost=0.00..12.85 rows=2 width=72) (actual time=0.009..0.010 rows=2 loops=1) + Filter: (((n_name)::text = 'FRANCE'::text) OR ((n_name)::text = 'GERMANY'::text)) + Rows Removed by Filter: 23 + -> Index Scan using orders_pkey on orders o (cost=0.43..6.30 rows=1 width=8) (actual time=0.001..0.001 rows=1 loops=1460257) + Index Cond: (o_orderkey = l.l_orderkey) + -> Index Scan using customer_pkey on customer c (cost=0.43..5.17 rows=1 width=8) (actual time=0.003..0.003 rows=1 loops=1460257) + Index Cond: (c_custkey = o.o_custkey) + -> Hash (cost=12.85..12.85 rows=2 width=72) (actual time=247.121..247.121 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=247.108..247.110 rows=2 loops=3) + Filter: (((n_name)::text = 'GERMANY'::text) OR ((n_name)::text = 'FRANCE'::text)) + Rows Removed by Filter: 23 +Planning Time: 0.589 ms +JIT: + Functions: 156 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.809 ms, Inlining 107.791 ms, Optimization 367.552 ms, Emission 266.054 ms, Total 746.206 ms +Execution Time: 4471.940 ms","GroupAggregate (cost=1147806.54..1147816.82 rows=1 width=200) (actual time=6120.426..11468.153 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=1147806.54..1147816.78 rows=1 width=204) (actual time=4329.227..11450.201 rows=58365 loops=1) + Join Filter: (nation_1.n_nationkey = customer.c_nationkey) + Rows Removed by Join Filter: 1401892 + -> Nested Loop (cost=1147806.11..1147811.60 rows=1 width=184) (actual time=4329.044..7275.292 rows=1460257 loops=1) + -> Gather Merge (cost=1147805.68..1147805.80 rows=1 width=184) (actual time=4329.003..4696.814 rows=1460257 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1146805.65..1146805.66 rows=1 width=184) (actual time=4243.132..4348.406 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: 23736kB + Worker 0: Sort Method: external merge Disk: 23640kB + Worker 1: Sort Method: external merge Disk: 35648kB + -> Parallel Hash Join (cost=2973.75..1146805.64 rows=1 width=184) (actual time=226.244..4001.750 rows=486752 loops=3) + Hash Cond: (lineitem.l_suppkey = supplier.s_suppkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1143493.15 rows=90330 width=48) (actual time=0.043..3264.904 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=226.012..226.017 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=203.652..208.996 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.010..3.587 rows=33333 loops=3) + -> Hash (cost=25.79..25.79 rows=1 width=144) (actual time=203.624..203.627 rows=2 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Nested Loop (cost=0.00..25.79 rows=1 width=144) (actual time=203.614..203.619 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=203.588..203.589 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.009..0.011 rows=2 loops=6) + -> Seq Scan on nation nation_1 (cost=0.00..12.85 rows=2 width=72) (actual time=0.014..0.016 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.80 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.003..0.003 rows=1 loops=1460257) + Index Cond: (c_custkey = orders.o_custkey) +Planning Time: 0.607 ms +JIT: + Functions: 111 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.981 ms, Inlining 105.180 ms, Optimization 308.392 ms, Emission 197.275 ms, Total 614.828 ms +Execution Time: 11479.395 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",2.8690438270000413,7.663431370999888,"Finalize GroupAggregate (cost=1749212.94..1749303.37 rows=631 width=64) (actual time=3526.536..3543.831 rows=2 loops=1) + Group Key: (EXTRACT(year FROM o.o_orderdate)) + -> Gather Merge (cost=1749212.94..1749284.18 rows=526 width=96) (actual time=3525.545..3543.810 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1748212.92..1748223.44 rows=263 width=96) (actual time=3514.720..3515.584 rows=2 loops=3) + Group Key: (EXTRACT(year FROM o.o_orderdate)) + -> Sort (cost=1748212.92..1748213.58 rows=263 width=112) (actual time=3513.685..3513.937 rows=8085 loops=3) + Sort Key: (EXTRACT(year FROM o.o_orderdate)) + Sort Method: quicksort Memory: 575kB + Worker 0: Sort Method: quicksort Memory: 552kB + Worker 1: Sort Method: quicksort Memory: 937kB + -> Hash Join (cost=445316.12..1748202.35 rows=263 width=112) (actual time=3479.126..3512.038 rows=8085 loops=3) + Hash Cond: (s.s_nationkey = n2.n_nationkey) + -> Nested Loop (cost=445301.85..1748186.72 rows=263 width=20) (actual time=3197.556..3228.890 rows=8085 loops=3) + -> Parallel Hash Join (cost=445301.55..1746834.17 rows=265 width=20) (actual time=3197.526..3217.568 rows=8085 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Hash Join (cost=47680.93..1348588.36 rows=166422 width=20) (actual time=41.001..2519.914 rows=134496 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235310.10 rows=24989410 width=24) (actual time=0.009..1213.443 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.56..47611.56 rows=5549 width=4) (actual time=40.885..40.886 rows=4484 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 704kB + -> Parallel Seq Scan on part p (cost=0.00..47611.56 rows=5549 width=4) (actual time=0.045..40.385 rows=4484 loops=3) + Filter: ((p_type)::text = 'ECONOMY ANODIZED STEEL'::text) + Rows Removed by Filter: 662183 + -> Parallel Hash (cost=397496.23..397496.23 rows=9952 width=8) (actual time=651.980..651.986 rows=303453 loops=3) + Buckets: 262144 (originally 32768) Batches: 8 (originally 1) Memory Usage: 6560kB + -> Parallel Hash Join (cost=44436.73..397496.23 rows=9952 width=8) (actual time=85.528..592.487 rows=303453 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..345926.84 rows=1890983 width=12) (actual time=0.027..340.110 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=44395.61..44395.61 rows=3290 width=4) (actual time=85.470..85.474 rows=99812 loops=3) + Buckets: 524288 (originally 8192) Batches: 1 (originally 1) Memory Usage: 19904kB + -> Hash Join (cost=24.81..44395.61 rows=3290 width=4) (actual time=0.075..69.415 rows=99812 loops=3) + Hash Cond: (c.c_nationkey = n1.n_nationkey) + -> Parallel Seq Scan on customer c (cost=0.00..41994.11 rows=625011 width=8) (actual time=0.026..38.003 rows=500000 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=4) (actual time=0.039..0.042 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.034..0.039 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.020..0.021 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.017..0.018 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.001..0.001 rows=1 loops=24254) + Index Cond: (s_suppkey = l.l_suppkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=281.540..281.541 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=281.515..281.521 rows=25 loops=3) +Planning Time: 0.741 ms +JIT: + Functions: 201 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.599 ms, Inlining 102.053 ms, Optimization 438.844 ms, Emission 303.960 ms, Total 849.456 ms +Execution Time: 3545.529 ms","Finalize GroupAggregate (cost=468050.33..468053.60 rows=21 width=40) (actual time=7313.132..7322.652 rows=2 loops=1) + Group Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Gather Merge (cost=468050.33..468052.79 rows=18 width=96) (actual time=7311.656..7322.605 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=467050.31..467050.69 rows=9 width=96) (actual time=7299.801..7301.119 rows=2 loops=3) + Group Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Sort (cost=467050.31..467050.33 rows=9 width=112) (actual time=7298.646..7299.220 rows=8085 loops=3) + Sort Key: (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + Sort Method: quicksort Memory: 615kB + Worker 0: Sort Method: quicksort Memory: 627kB + Worker 1: Sort Method: quicksort Memory: 630kB + -> Hash Join (cost=44452.29..467050.17 rows=9 width=112) (actual time=109.558..7295.484 rows=8085 loops=3) + Hash Cond: (supplier.s_nationkey = nation_2.n_nationkey) + -> Nested Loop (cost=44438.02..467035.82 rows=9 width=20) (actual time=96.829..7278.966 rows=8085 loops=3) + -> Nested Loop (cost=44437.73..466989.89 rows=9 width=20) (actual time=96.740..7237.698 rows=8085 loops=3) + -> Nested Loop (cost=44437.30..460065.37 rows=1315 width=24) (actual time=94.466..2939.278 rows=1212976 loops=3) + -> Parallel Hash Join (cost=44436.73..406223.10 rows=329 width=8) (actual time=94.164..1487.892 rows=303453 loops=3) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Parallel Seq Scan on orders (cost=0.00..361550.64 rows=62495 width=12) (actual time=0.042..853.938 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=44395.61..44395.61 rows=3290 width=4) (actual time=93.955..93.959 rows=99812 loops=3) + Buckets: 524288 (originally 8192) Batches: 1 (originally 1) Memory Usage: 19872kB + -> Hash Join (cost=24.81..44395.61 rows=3290 width=4) (actual time=0.125..74.374 rows=99812 loops=3) + Hash Cond: (customer.c_nationkey = nation.n_nationkey) + -> Parallel Seq Scan on customer (cost=0.00..41994.11 rows=625011 width=8) (actual time=0.015..39.970 rows=500000 loops=3) + -> Hash (cost=24.80..24.80 rows=1 width=4) (actual time=0.102..0.106 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.097..0.102 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.004 rows=25 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.086..0.087 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.083..0.084 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..162.32 rows=133 width=24) (actual time=0.004..0.004 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.003..0.003 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.005..0.005 rows=1 loops=24254) + Index Cond: (s_suppkey = lineitem.l_suppkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=12.697..12.697 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=12.677..12.680 rows=25 loops=3) +Planning Time: 2.684 ms +JIT: + Functions: 180 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 4.536 ms, Inlining 0.000 ms, Optimization 1.835 ms, Emission 36.454 ms, Total 42.824 ms +Execution Time: 7324.382 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",14.681650238999964,12.02899629400008,"Finalize GroupAggregate (cost=1656937.35..1656946.99 rows=71 width=132) (actual time=13784.105..14249.056 rows=175 loops=1) + Group Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) + -> Gather Merge (cost=1656937.35..1656945.33 rows=60 width=132) (actual time=13780.353..14248.867 rows=525 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1655937.33..1655938.38 rows=30 width=132) (actual time=13478.653..13828.573 rows=175 loops=3) + Group Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) + -> Sort (cost=1655937.33..1655937.40 rows=30 width=123) (actual time=13476.909..13559.838 rows=1087204 loops=3) + Sort Key: n.n_name, (EXTRACT(year FROM o.o_orderdate)) DESC + Sort Method: external merge Disk: 53288kB + Worker 0: Sort Method: external merge Disk: 47392kB + Worker 1: Sort Method: external merge Disk: 54352kB + -> Hash Join (cost=322612.32..1655936.59 rows=30 width=123) (actual time=6174.672..12597.313 rows=1087204 loops=3) + Hash Cond: (s.s_nationkey = n.n_nationkey) + -> Nested Loop (cost=322598.04..1655922.16 rows=30 width=31) (actual time=5940.364..12127.563 rows=1087204 loops=3) + -> Nested Loop (cost=322597.61..1655752.82 rows=30 width=31) (actual time=5940.324..8001.066 rows=1087204 loops=3) + -> Parallel Hash Join (cost=322597.32..1655590.37 rows=30 width=35) (actual time=5940.168..6558.299 rows=1087204 loops=3) + Hash Cond: ((p.p_partkey = ps.ps_partkey) AND (l.l_suppkey = ps.ps_suppkey)) + -> Parallel Hash Join (cost=47927.19..1348834.62 rows=757260 width=33) (actual time=73.135..2776.435 rows=1087204 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235310.10 rows=24989410 width=29) (actual time=0.012..1230.492 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.56..47611.56 rows=25250 width=4) (actual time=73.017..73.018 rows=36261 loops=3) + Buckets: 131072 (originally 65536) Batches: 1 (originally 1) Memory Usage: 5824kB + -> Parallel Seq Scan on part p (cost=0.00..47611.56 rows=25250 width=4) (actual time=0.064..64.792 rows=36261 loops=3) + Filter: ((p_name)::text ~~ '%green%'::text) + Rows Removed by Filter: 630406 + -> Parallel Hash (cost=208397.25..208397.25 rows=3333125 width=14) (actual time=2960.014..2960.015 rows=2666667 loops=3) + Buckets: 262144 Batches: 64 Memory Usage: 8000kB + -> Parallel Seq Scan on partsupp ps (cost=0.00..208397.25 rows=3333125 width=14) (actual time=0.984..2688.034 rows=2666667 loops=3) + -> Index Scan using supplier_pkey on supplier s (cost=0.29..5.42 rows=1 width=8) (actual time=0.001..0.001 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.004..0.004 rows=1 loops=3261613) + Index Cond: (o_orderkey = l.l_orderkey) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=234.285..234.286 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=234.257..234.263 rows=25 loops=3) +Planning Time: 25.907 ms +JIT: + Functions: 141 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 45.528 ms, Inlining 147.110 ms, Optimization 318.880 ms, Emission 237.105 ms, Total 748.624 ms +Execution Time: 14298.803 ms","Finalize GroupAggregate (cost=1639344.60..1639355.18 rows=77 width=132) (actual time=12935.058..13311.086 rows=175 loops=1) + Group Key: nation.n_name, (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Gather Merge (cost=1639344.60..1639353.19 rows=64 width=132) (actual time=12931.934..13310.896 rows=525 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1638344.58..1638345.78 rows=32 width=132) (actual time=12632.751..12965.972 rows=175 loops=3) + Group Key: nation.n_name, (EXTRACT(year FROM (orders.o_orderdate)::timestamp without time zone)) + -> Sort (cost=1638344.58..1638344.66 rows=32 width=123) (actual time=12631.063..12709.786 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: 46904kB + Worker 0: Sort Method: external merge Disk: 46656kB + Worker 1: Sort Method: external merge Disk: 61456kB + -> Nested Loop (cost=1366125.52..1638343.78 rows=32 width=123) (actual time=3845.434..11900.206 rows=1087204 loops=3) + -> Hash Join (cost=1366125.09..1638162.98 rows=32 width=95) (actual time=3845.389..6276.045 rows=1087204 loops=3) + Hash Cond: (supplier.s_nationkey = nation.n_nationkey) + -> Nested Loop (cost=1366110.81..1638148.63 rows=32 width=31) (actual time=3618.411..5903.825 rows=1087204 loops=3) + -> Parallel Hash Join (cost=1366110.52..1637975.34 rows=32 width=35) (actual time=3618.359..4752.428 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..208397.25 rows=3333125 width=14) (actual time=0.052..211.384 rows=2666667 loops=3) + -> Parallel Hash (cost=1348834.62..1348834.62 rows=757260 width=33) (actual time=3112.154..3112.159 rows=1087204 loops=3) + Buckets: 131072 Batches: 32 Memory Usage: 8384kB + -> Parallel Hash Join (cost=47927.19..1348834.62 rows=757260 width=33) (actual time=65.582..2913.979 rows=1087204 loops=3) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1235310.10 rows=24989410 width=29) (actual time=0.011..1304.093 rows=19995351 loops=3) + -> Parallel Hash (cost=47611.56..47611.56 rows=25250 width=4) (actual time=65.483..65.484 rows=36261 loops=3) + Buckets: 131072 (originally 65536) Batches: 1 (originally 1) Memory Usage: 5824kB + -> Parallel Seq Scan on part (cost=0.00..47611.56 rows=25250 width=4) (actual time=0.036..60.133 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=226.956..226.956 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=226.930..226.936 rows=25 loops=3) + -> Index Scan using orders_pkey on orders (cost=0.43..5.64 rows=1 width=8) (actual time=0.005..0.005 rows=1 loops=3261613) + Index Cond: (o_orderkey = lineitem.l_orderkey) +Planning Time: 1.108 ms +JIT: + Functions: 141 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.987 ms, Inlining 112.048 ms, Optimization 331.797 ms, Emission 237.249 ms, Total 685.081 ms +Execution Time: 13317.794 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",3.7054452909999327,4.209320711999908,"Limit (cost=1951421.44..1951421.49 rows=20 width=244) (actual time=3886.470..4017.872 rows=20 loops=1) + -> Sort (cost=1951421.44..1952925.72 rows=601710 width=244) (actual time=3757.093..3888.493 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=1858103.19..1935410.16 rows=601710 width=244) (actual time=3341.869..3820.976 rows=381105 loops=1) + Group Key: c.c_custkey, n.n_name + -> Gather Merge (cost=1858103.19..1922874.54 rows=501424 width=244) (actual time=3341.858..3652.730 rows=381962 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1857103.17..1863997.75 rows=250712 width=244) (actual time=3330.207..3483.729 rows=127321 loops=3) + Group Key: c.c_custkey, n.n_name + -> Sort (cost=1857103.17..1857729.95 rows=250712 width=224) (actual time=3330.157..3360.691 rows=382361 loops=3) + Sort Key: c.c_custkey, n.n_name + Sort Method: external merge Disk: 58024kB + Worker 0: Sort Method: external merge Disk: 56944kB + Worker 1: Sort Method: external merge Disk: 83776kB + -> Hash Join (cost=413214.20..1808054.72 rows=250712 width=224) (actual time=3042.625..3162.490 rows=382361 loops=3) + Hash Cond: (c.c_nationkey = n.n_nationkey) + -> Parallel Hash Join (cost=413199.92..1807367.65 rows=250712 width=160) (actual time=2924.474..3009.659 rows=382361 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Hash Join (cost=349965.18..1727596.78 rows=250712 width=16) (actual time=2385.610..2704.168 rows=382361 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1297783.62 rows=6366469 width=16) (actual time=0.044..1523.343 rows=4936061 loops=3) + Filter: (l_returnflag = 'R'::bpchar) + Rows Removed by Filter: 15059290 + -> Parallel Hash (cost=345926.84..345926.84 rows=246107 width=8) (actual time=313.491..313.492 rows=191052 loops=3) + Buckets: 262144 Batches: 4 Memory Usage: 7712kB + -> Parallel Seq Scan on orders o (cost=0.00..345926.84 rows=246107 width=8) (actual time=0.039..285.245 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.11..41994.11 rows=625011 width=148) (actual time=171.833..171.833 rows=500000 loops=3) + Buckets: 65536 Batches: 64 Memory Usage: 4832kB + -> Parallel Seq Scan on customer c (cost=0.00..41994.11 rows=625011 width=148) (actual time=0.028..53.420 rows=500000 loops=3) + -> Hash (cost=11.90..11.90 rows=190 width=72) (actual time=118.130..118.131 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=118.111..118.114 rows=25 loops=3) +Planning Time: 1.207 ms +JIT: + Functions: 109 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.356 ms, Inlining 94.902 ms, Optimization 228.231 ms, Emission 160.903 ms, Total 487.393 ms +Execution Time: 4026.107 ms","Limit (cost=624224.16..624224.21 rows=20 width=244) (actual time=3065.262..3065.358 rows=20 loops=1) + -> Sort (cost=624224.16..627974.22 rows=1500026 width=244) (actual time=2945.082..2945.177 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: 31kB + -> Hash Join (cost=525601.77..584309.01 rows=1500026 width=244) (actual time=2052.699..2755.094 rows=1500000 loops=1) + Hash Cond: (customer.c_nationkey = nation.n_nationkey) + -> Hash Left Join (cost=525587.49..580269.33 rows=1500026 width=180) (actual time=2052.663..2641.737 rows=1500000 loops=1) + Hash Cond: (customer.c_custkey = _s3.o_custkey) + -> Seq Scan on customer (cost=0.00..50744.26 rows=1500026 width=148) (actual time=0.006..123.361 rows=1500000 loops=1) + -> Hash (cost=525573.44..525573.44 rows=1124 width=36) (actual time=2052.637..2052.728 rows=381105 loops=1) + Buckets: 262144 (originally 2048) Batches: 4 (originally 1) Memory Usage: 6514kB + -> Subquery Scan on _s3 (cost=525418.68..525573.44 rows=1124 width=36) (actual time=1688.573..2015.617 rows=381105 loops=1) + -> Finalize GroupAggregate (cost=525418.68..525562.20 rows=1124 width=36) (actual time=1688.570..1996.000 rows=381105 loops=1) + Group Key: orders.o_custkey + -> Gather Merge (cost=525418.68..525540.98 rows=956 width=36) (actual time=1688.560..1863.054 rows=449660 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=524418.66..524430.61 rows=478 width=36) (actual time=1672.966..1804.754 rows=149887 loops=3) + Group Key: orders.o_custkey + -> Sort (cost=524418.66..524419.86 rows=478 width=16) (actual time=1672.929..1699.133 rows=382361 loops=3) + Sort Key: orders.o_custkey + Sort Method: external merge Disk: 10800kB + Worker 0: Sort Method: external merge Disk: 8384kB + Worker 1: Sort Method: external merge Disk: 11760kB + -> Nested Loop (cost=0.56..524397.39 rows=478 width=16) (actual time=83.688..1572.709 rows=382361 loops=3) + -> Parallel Seq Scan on orders (cost=0.00..416233.97 rows=469 width=8) (actual time=83.585..817.919 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..230.29 rows=34 width=16) (actual time=0.003..0.004 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.026..0.026 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.018..0.019 rows=25 loops=1) +Planning Time: 0.962 ms +JIT: + Functions: 67 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.348 ms, Inlining 106.204 ms, Optimization 152.183 ms, Emission 112.582 ms, Total 374.316 ms +Execution Time: 3067.886 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",2.8192927729999155,2.8950720909999745,"Sort (cost=457435.89..457470.64 rows=13900 width=36) (actual time=958.298..963.200 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=225027.37..225027.38 rows=1 width=32) (actual time=406.425..406.655 rows=1 loops=1) + -> Gather (cost=225027.14..225027.35 rows=2 width=32) (actual time=406.337..406.641 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=224027.14..224027.15 rows=1 width=32) (actual time=396.667..396.668 rows=1 loops=3) + -> Parallel Hash Join (cost=2898.35..223896.83 rows=17375 width=10) (actual time=9.469..378.466 rows=107973 loops=3) + Hash Cond: (ps2.ps_suppkey = s2.s_suppkey) + -> Parallel Seq Scan on partsupp ps2 (cost=0.00..208397.25 rows=3333125 width=14) (actual time=0.019..183.745 rows=2666667 loops=3) + -> Parallel Hash (cost=2894.48..2894.48 rows=309 width=4) (actual time=9.253..9.254 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=3.042..7.588 rows=1350 loops=3) + 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.006..1.792 rows=33333 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=3.021..3.022 rows=1 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation n2 (cost=0.00..12.38 rows=1 width=4) (actual time=3.016..3.017 rows=1 loops=3) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 + -> Finalize GroupAggregate (cost=226120.46..231451.99 rows=13900 width=36) (actual time=958.295..962.966 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=226120.46..230565.85 rows=34750 width=36) (actual time=409.886..472.656 rows=304796 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=225120.44..225554.82 rows=17375 width=36) (actual time=399.968..448.163 rows=101599 loops=3) + Group Key: ps.ps_partkey + -> Sort (cost=225120.44..225163.88 rows=17375 width=14) (actual time=399.932..405.884 rows=107973 loops=3) + Sort Key: ps.ps_partkey + Sort Method: external merge Disk: 2472kB + Worker 0: Sort Method: external merge Disk: 2504kB + Worker 1: Sort Method: external merge Disk: 3288kB + -> Parallel Hash Join (cost=2898.35..223896.83 rows=17375 width=14) (actual time=14.740..381.676 rows=107973 loops=3) + Hash Cond: (ps.ps_suppkey = s.s_suppkey) + -> Parallel Seq Scan on partsupp ps (cost=0.00..208397.25 rows=3333125 width=18) (actual time=0.017..186.547 rows=2666667 loops=3) + -> Parallel Hash (cost=2894.48..2894.48 rows=309 width=4) (actual time=14.588..14.590 rows=1350 loops=3) + Buckets: 4096 (originally 1024) Batches: 1 (originally 1) Memory Usage: 280kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=4) (actual time=7.963..12.571 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.003..2.146 rows=33333 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=7.944..7.945 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=7.936..7.938 rows=1 loops=3) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 +Planning Time: 0.274 ms +JIT: + Functions: 147 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.815 ms, Inlining 0.000 ms, Optimization 1.894 ms, Emission 31.065 ms, Total 36.774 ms +Execution Time: 964.976 ms","Limit (cost=895980.12..895980.14 rows=10 width=36) (actual time=3430.705..3430.714 rows=0 loops=1) + CTE _s0 + -> Seq Scan on supplier (cost=0.00..3136.00 rows=100000 width=8) (actual time=0.015..6.335 rows=100000 loops=1) + CTE _t2 + -> Seq Scan on nation (cost=0.00..12.38 rows=1 width=72) (actual time=0.008..0.009 rows=1 loops=1) + Filter: ((n_name)::text = 'GERMANY'::text) + Rows Removed by Filter: 24 + -> Sort (cost=892831.74..892864.75 rows=13205 width=36) (actual time=3304.296..3304.304 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=890961.74..892546.39 rows=13205 width=36) (actual time=3304.288..3304.295 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=436304.71..436304.72 rows=1 width=32) (actual time=1647.717..1647.721 rows=1 loops=1) + -> Hash Join (cost=394115.81..436007.59 rows=39616 width=10) (actual time=1174.807..1619.168 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.048..21.695 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.017..17.512 rows=100000 loops=1) + -> Hash (cost=0.02..0.02 rows=1 width=4) (actual time=0.015..0.016 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.010..0.012 rows=1 loops=1) + -> Hash (cost=255061.01..255061.01 rows=7999501 width=14) (actual time=1172.678..1172.679 rows=8000000 loops=1) + Buckets: 262144 (originally 262144) Batches: 128 (originally 64) Memory Usage: 8116kB + -> Seq Scan on partsupp (cost=0.00..255061.01 rows=7999501 width=14) (actual time=0.032..519.364 rows=8000000 loops=1) + -> GroupAggregate (cost=454657.02..455647.42 rows=39616 width=36) (actual time=1536.065..1635.738 rows=304774 loops=1) + Group Key: partsupp_1.ps_partkey + -> Sort (cost=454657.02..454756.06 rows=39616 width=14) (actual time=1536.028..1549.397 rows=323920 loops=1) + Sort Key: partsupp_1.ps_partkey + Sort Method: external sort Disk: 9544kB + -> Hash Join (cost=401927.81..451631.59 rows=39616 width=14) (actual time=1220.454..1475.860 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.031..7.503 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.011..3.953 rows=100000 loops=1) + -> Hash (cost=0.02..0.02 rows=1 width=4) (actual time=0.007..0.007 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.003..0.003 rows=1 loops=1) + -> Hash (cost=255061.01..255061.01 rows=7999501 width=18) (actual time=1219.442..1219.443 rows=8000000 loops=1) + Buckets: 131072 Batches: 64 Memory Usage: 7403kB + -> Seq Scan on partsupp partsupp_1 (cost=0.00..255061.01 rows=7999501 width=18) (actual time=0.042..550.206 rows=8000000 loops=1) +Planning Time: 0.229 ms +JIT: + Functions: 52 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.575 ms, Inlining 6.890 ms, Optimization 68.964 ms, Emission 50.676 ms, Total 128.104 ms +Execution Time: 3434.857 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",3.1304061309999724,2.031349158000012,"Finalize GroupAggregate (cost=2016709.45..2019200.11 rows=7 width=21) (actual time=3312.022..3395.402 rows=2 loops=1) + Group Key: l.l_shipmode + -> Gather Merge (cost=2016709.45..2019199.93 rows=14 width=21) (actual time=3305.321..3395.381 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=2015709.42..2018198.29 rows=7 width=21) (actual time=3287.816..3294.508 rows=2 loops=3) + Group Key: l.l_shipmode + -> Sort (cost=2015709.42..2016020.52 rows=124440 width=14) (actual time=3279.955..3285.606 rows=103601 loops=3) + Sort Key: l.l_shipmode + Sort Method: external merge Disk: 2104kB + Worker 0: Sort Method: external merge Disk: 2000kB + Worker 1: Sort Method: external merge Disk: 3336kB + -> Parallel Hash Join (cost=423314.25..2003050.63 rows=124440 width=14) (actual time=3034.057..3267.898 rows=103601 loops=3) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1547677.73 rows=124440 width=9) (actual time=0.105..1944.540 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=314679.22..314679.22 rows=6249522 width=13) (actual time=1058.543..1058.544 rows=5000000 loops=3) + Buckets: 262144 Batches: 128 Memory Usage: 7808kB + -> Parallel Seq Scan on orders o (cost=0.00..314679.22 rows=6249522 width=13) (actual time=122.581..525.749 rows=5000000 loops=3) +Planning Time: 0.243 ms +JIT: + Functions: 54 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.235 ms, Inlining 98.534 ms, Optimization 157.426 ms, Emission 111.927 ms, Total 372.121 ms +Execution Time: 3398.620 ms","Finalize GroupAggregate (cost=1703513.74..1703571.28 rows=7 width=21) (actual time=1942.243..1944.222 rows=2 loops=1) + Group Key: lineitem.l_shipmode + -> Gather Merge (cost=1703513.74..1703571.11 rows=14 width=21) (actual time=1933.455..1944.203 rows=6 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1702513.72..1702569.47 rows=7 width=21) (actual time=1916.106..1923.873 rows=2 loops=3) + Group Key: lineitem.l_shipmode + -> Sort (cost=1702513.72..1702523.00 rows=3712 width=14) (actual time=1906.578..1912.119 rows=103601 loops=3) + Sort Key: lineitem.l_shipmode NULLS FIRST + Sort Method: external merge Disk: 2224kB + Worker 0: Sort Method: external merge Disk: 2128kB + Worker 1: Sort Method: external merge Disk: 3080kB + -> Nested Loop (cost=0.43..1702293.64 rows=3712 width=14) (actual time=135.476..1885.975 rows=103601 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1672624.78 rows=3712 width=9) (actual time=135.411..1622.824 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..7.99 rows=1 width=13) (actual time=0.002..0.002 rows=1 loops=310803) + Index Cond: (o_orderkey = lineitem.l_orderkey) +Planning Time: 0.624 ms +JIT: + Functions: 42 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.304 ms, Inlining 106.265 ms, Optimization 175.640 ms, Emission 124.248 ms, Total 408.457 ms +Execution Time: 1945.536 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",3.498640855000076,2.995057395999993,"Limit (cost=1409111.31..1409111.33 rows=10 width=16) (actual time=3856.721..3916.239 rows=10 loops=1) + -> Sort (cost=1409111.31..1409111.81 rows=200 width=16) (actual time=3809.634..3869.151 rows=10 loops=1) + Sort Key: (count(*)) DESC, (count(o.o_orderkey)) DESC + Sort Method: top-N heapsort Memory: 25kB + -> HashAggregate (cost=1409104.99..1409106.99 rows=200 width=16) (actual time=3809.618..3869.137 rows=46 loops=1) + Group Key: count(o.o_orderkey) + Batches: 1 Memory Usage: 40kB + -> Finalize HashAggregate (cost=1342306.95..1386604.60 rows=1500026 width=12) (actual time=3507.562..3795.419 rows=1500000 loops=1) + Group Key: c.c_custkey + Planned Partitions: 32 Batches: 33 Memory Usage: 8209kB Disk Usage: 63288kB + -> Gather (cost=786779.44..1150116.12 rows=3000052 width=12) (actual time=2874.876..3366.219 rows=1675186 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=785779.44..849110.92 rows=1500026 width=12) (actual time=2867.594..3208.502 rows=558395 loops=3) + Group Key: c.c_custkey + Planned Partitions: 32 Batches: 33 Memory Usage: 8209kB Disk Usage: 96120kB + Worker 0: Batches: 33 Memory Usage: 8209kB Disk Usage: 128192kB + Worker 1: Batches: 33 Memory Usage: 8209kB Disk Usage: 161152kB + -> Parallel Hash Right Join (cost=40478.30..437794.67 rows=6186396 width=8) (actual time=1482.643..2168.489 rows=5112535 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..330303.03 rows=6186396 width=8) (actual time=0.047..909.777 rows=4945861 loops=3) + Filter: ((o_comment)::text !~~ '%special%requests%'::text) + Rows Removed by Filter: 54139 + -> Parallel Hash (cost=30223.67..30223.67 rows=625011 width=4) (actual time=121.339..121.340 rows=500000 loops=3) + Buckets: 262144 Batches: 16 Memory Usage: 5760kB + -> Parallel Index Only Scan using customer_pkey on customer c (cost=0.43..30223.67 rows=625011 width=4) (actual time=0.017..32.149 rows=500000 loops=3) + Heap Fetches: 0 +Planning Time: 0.212 ms +JIT: + Functions: 63 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.849 ms, Inlining 92.214 ms, Optimization 93.907 ms, Emission 76.660 ms, Total 265.631 ms +Execution Time: 3937.091 ms","Limit (cost=1122262.23..1122262.26 rows=10 width=16) (actual time=3352.744..3385.472 rows=10 loops=1) + -> Sort (cost=1122262.23..1122262.73 rows=200 width=16) (actual time=3309.793..3342.520 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=1122255.91..1122257.91 rows=200 width=16) (actual time=3309.776..3342.507 rows=46 loops=1) + Group Key: COALESCE((count(*)), '0'::bigint) + Batches: 1 Memory Usage: 40kB + -> Merge Left Join (cost=835399.96..1114755.78 rows=1500026 width=8) (actual time=2613.448..3262.076 rows=1500000 loops=1) + Merge Cond: (customer.c_custkey = orders.o_custkey) + -> Index Only Scan using customer_pkey on customer (cost=0.43..38973.82 rows=1500026 width=4) (actual time=0.016..75.132 rows=1500000 loops=1) + Heap Fetches: 0 + -> Finalize GroupAggregate (cost=835399.54..1052730.70 rows=857831 width=12) (actual time=2613.422..3049.557 rows=999979 loops=1) + Group Key: orders.o_custkey + -> Gather Merge (cost=835399.54..1035574.08 rows=1715662 width=12) (actual time=2613.379..2884.515 rows=2930989 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=834399.51..836544.09 rows=857831 width=12) (actual time=2565.250..2611.068 rows=976996 loops=3) + Sort Key: orders.o_custkey + Sort Method: external merge Disk: 24760kB + Worker 0: Sort Method: external merge Disk: 24648kB + Worker 1: Sort Method: external merge Disk: 25296kB + -> Partial HashAggregate (cost=678287.81..735197.34 rows=857831 width=12) (actual time=1844.365..2333.240 rows=976996 loops=3) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 17 Memory Usage: 8337kB Disk Usage: 129512kB + Worker 0: Batches: 17 Memory Usage: 8337kB Disk Usage: 129168kB + Worker 1: Batches: 17 Memory Usage: 8337kB Disk Usage: 180264kB + -> Parallel Seq Scan on orders (cost=0.00..330303.03 rows=6186396 width=4) (actual time=44.616..937.373 rows=4945861 loops=3) + Filter: ((o_comment)::text !~~ '%special%requests%'::text) + Rows Removed by Filter: 54139 +Planning Time: 0.183 ms +JIT: + Functions: 38 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.875 ms, Inlining 88.028 ms, Optimization 62.220 ms, Emission 57.550 ms, Total 209.674 ms +Execution Time: 3404.133 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",1.5349774100000104,3.7320269070000904,"Finalize Aggregate (cost=1437654.18..1437654.20 rows=1 width=32) (actual time=1552.753..1575.437 rows=1 loops=1) + -> Gather (cost=1437653.95..1437654.16 rows=2 width=64) (actual time=1552.084..1575.421 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1436653.95..1436653.96 rows=1 width=64) (actual time=1539.553..1539.828 rows=1 loops=3) + -> Parallel Hash Join (cost=61641.01..1431350.66 rows=303045 width=33) (actual time=1431.684..1488.710 rows=249741 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1360257.15 rows=303045 width=16) (actual time=0.064..1174.937 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.45..45528.45 rows=833245 width=25) (actual time=214.058..214.059 rows=666667 loops=3) + Buckets: 131072 Batches: 32 Memory Usage: 4864kB + -> Parallel Seq Scan on part p (cost=0.00..45528.45 rows=833245 width=25) (actual time=86.204..141.065 rows=666667 loops=3) +Planning Time: 0.189 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.984 ms, Inlining 97.944 ms, Optimization 87.137 ms, Emission 73.591 ms, Total 260.656 ms +Execution Time: 1576.283 ms","Finalize Aggregate (cost=1616091.99..1616092.00 rows=1 width=32) (actual time=3697.506..3709.169 rows=1 loops=1) + -> Gather (cost=1616091.75..1616091.96 rows=2 width=64) (actual time=3697.357..3709.152 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1615091.75..1615091.76 rows=1 width=64) (actual time=3688.073..3688.074 rows=1 loops=3) + -> Nested Loop (cost=0.43..1615080.81 rows=625 width=33) (actual time=101.190..3615.133 rows=249741 loops=3) + -> Parallel Seq Scan on lineitem (cost=0.00..1610151.25 rows=625 width=16) (actual time=101.128..2838.818 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.003..0.003 rows=1 loops=749223) + Index Cond: (p_partkey = lineitem.l_partkey) +Planning Time: 0.182 ms +JIT: + Functions: 32 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.856 ms, Inlining 106.800 ms, Optimization 110.301 ms, Emission 86.180 ms, Total 305.137 ms +Execution Time: 3710.006 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",1.953043163999837,3.127023931999929,"Sort (cost=1480355.71..1480356.97 rows=504 width=97) (actual time=2029.978..2030.189 rows=1 loops=1) + Sort Key: s.s_suppkey + Sort Method: quicksort Memory: 25kB + CTE revenue + -> Finalize GroupAggregate (cost=1446504.02..1472783.31 rows=100745 width=36) (actual time=1910.834..2002.408 rows=100000 loops=1) + Group Key: l.l_suppkey + -> Gather Merge (cost=1446504.02..1470012.83 rows=201490 width=36) (actual time=1910.789..1941.912 rows=299678 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1445503.99..1445755.86 rows=100745 width=36) (actual time=1886.136..1892.728 rows=99893 loops=3) + Sort Key: l.l_suppkey + Sort Method: external merge Disk: 7936kB + Worker 0: Sort Method: external merge Disk: 7928kB + Worker 1: Sort Method: external merge Disk: 7928kB + -> Partial HashAggregate (cost=1424088.65..1434373.91 rows=100745 width=36) (actual time=1655.445..1860.447 rows=99893 loops=3) + Group Key: l.l_suppkey + Planned Partitions: 4 Batches: 21 Memory Usage: 8249kB Disk Usage: 35816kB + Worker 0: Batches: 21 Memory Usage: 8249kB Disk Usage: 23864kB + Worker 1: Batches: 21 Memory Usage: 8249kB Disk Usage: 23856kB + -> Parallel Seq Scan on lineitem l (cost=0.00..1360257.15 rows=924257 width=16) (actual time=100.656..1317.218 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=2266.76..2266.77 rows=1 width=32) (actual time=109.102..109.103 rows=1 loops=1) + -> CTE Scan on revenue (cost=0.00..2014.90 rows=100745 width=32) (actual time=0.001..103.342 rows=100000 loops=1) + -> Nested Loop (cost=0.29..5283.00 rows=504 width=97) (actual time=2026.957..2029.975 rows=1 loops=1) + -> CTE Scan on revenue r (cost=0.00..2266.76 rows=504 width=36) (actual time=2026.910..2029.927 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.98 rows=1 width=65) (actual time=0.023..0.023 rows=1 loops=1) + Index Cond: (s_suppkey = r.supplier_no) +Planning Time: 0.181 ms +JIT: + Functions: 50 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.229 ms, Inlining 129.063 ms, Optimization 199.065 ms, Emission 133.522 ms, Total 464.880 ms +Execution Time: 2036.360 ms","Sort (cost=1716189.03..1716189.03 rows=1 width=97) (actual time=3105.077..3105.168 rows=1 loops=1) + Sort Key: supplier.s_suppkey NULLS FIRST + Sort Method: quicksort Memory: 25kB + CTE _t3 + -> Gather (cost=1000.00..1583078.85 rows=2218217 width=20) (actual time=108.234..908.140 rows=2265714 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on lineitem (cost=0.00..1360257.15 rows=924257 width=20) (actual time=79.192..1318.540 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=133098.33..133110.17 rows=1 width=97) (actual time=3007.924..3105.075 rows=1 loops=1) + -> Hash Join (cost=133098.04..133103.08 rows=1 width=36) (actual time=3007.894..3105.044 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=66546.51..66549.01 rows=200 width=36) (actual time=1725.458..2095.402 rows=100000 loops=1) + Group Key: _t3.l_suppkey + Batches: 21 Memory Usage: 8265kB Disk Usage: 69480kB + -> CTE Scan on _t3 (cost=0.00..44364.34 rows=2218217 width=40) (actual time=108.238..1151.246 rows=2265714 loops=1) + -> Hash (cost=66551.52..66551.52 rows=1 width=32) (actual time=1005.511..1005.512 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Aggregate (cost=66551.51..66551.52 rows=1 width=32) (actual time=1005.505..1005.506 rows=1 loops=1) + -> HashAggregate (cost=66546.51..66549.01 rows=200 width=36) (actual time=636.261..1002.568 rows=100000 loops=1) + Group Key: _t3_1.l_suppkey + Batches: 21 Memory Usage: 8265kB Disk Usage: 69480kB + -> CTE Scan on _t3 _t3_1 (cost=0.00..44364.34 rows=2218217 width=40) (actual time=0.008..100.617 rows=2265714 loops=1) + -> Index Scan using supplier_pkey on supplier (cost=0.29..7.09 rows=1 width=65) (actual time=0.022..0.022 rows=1 loops=1) + Index Cond: (s_suppkey = _t3.l_suppkey) +Planning Time: 0.217 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.150 ms, Inlining 103.228 ms, Optimization 124.348 ms, Emission 83.452 ms, Total 313.179 ms +Execution Time: 3131.468 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",1.8974875260000772,1.3323797150001155,"Limit (cost=361954.59..361954.61 rows=10 width=42) (actual time=1796.946..1834.639 rows=10 loops=1) + -> Sort (cost=361954.59..362338.64 rows=153619 width=42) (actual time=1791.736..1829.428 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=282128.66..358634.94 rows=153619 width=42) (actual time=1421.122..1826.292 rows=27840 loops=1) + Group Key: p.p_brand, p.p_type, p.p_size + -> Gather Merge (cost=282128.66..351170.69 rows=592806 width=38) (actual time=1421.068..1741.582 rows=1186602 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=281128.64..281746.14 rows=247002 width=38) (actual time=1404.087..1546.515 rows=395534 loops=3) + Sort Key: p.p_brand, p.p_type, p.p_size, ps.ps_suppkey + Sort Method: external merge Disk: 15608kB + Worker 0: Sort Method: external merge Disk: 15608kB + Worker 1: Sort Method: external merge Disk: 27112kB + -> Parallel Hash Join (cost=63924.78..252249.47 rows=247002 width=38) (actual time=659.896..826.613 rows=395534 loops=3) + Hash Cond: (ps.ps_partkey = p.p_partkey) + -> Parallel Index Only Scan using partsupp_pkey on partsupp ps (cost=3388.96..173351.91 rows=1666562 width=8) (actual time=13.533..315.318 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=1010 width=4) (actual time=0.214..13.230 rows=56 loops=3) + Filter: ((s_comment)::text ~~ '%Customer%Complaints%'::text) + Rows Removed by Filter: 99944 + -> Parallel Hash (cost=58027.12..58027.12 rows=123496 width=38) (actual time=104.977..104.977 rows=98941 loops=3) + Buckets: 131072 Batches: 4 Memory Usage: 6432kB + -> Parallel Seq Scan on part p (cost=0.00..58027.12 rows=123496 width=38) (actual time=3.605..88.316 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.314 ms +JIT: + Functions: 79 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 2.636 ms, Inlining 0.000 ms, Optimization 1.322 ms, Emission 15.241 ms, Total 19.198 ms +Execution Time: 1837.523 ms","Limit (cost=443289.15..443289.18 rows=10 width=42) (actual time=1352.043..1362.782 rows=10 loops=1) + -> Sort (cost=443289.15..443679.52 rows=156147 width=42) (actual time=1348.036..1358.774 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=285223.74..439914.87 rows=156147 width=42) (actual time=959.020..1355.627 rows=29000 loops=1) + Group Key: part.p_brand, part.p_type, part.p_size + -> Gather Merge (cost=285223.74..426245.08 rows=1210832 width=38) (actual time=958.971..1266.493 rows=1235619 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=284223.72..285485.00 rows=504513 width=38) (actual time=927.542..1085.251 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: 17544kB + Worker 0: Sort Method: external merge Disk: 16496kB + Worker 1: Sort Method: external merge Disk: 26688kB + -> Parallel Hash Join (cost=3599.59..222637.91 rows=504513 width=38) (actual time=14.050..325.315 rows=411873 loops=3) + Hash Cond: (partsupp.ps_suppkey = supplier.s_suppkey) + -> Nested Loop (cost=0.43..217687.95 rows=514569 width=38) (actual time=0.084..253.680 rows=412112 loops=3) + -> Parallel Seq Scan on part (cost=0.00..58027.12 rows=128637 width=38) (actual time=0.034..90.648 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.05 rows=19 width=8) (actual time=0.001..0.001 rows=4 loops=309084) + Index Cond: (ps_partkey = part.p_partkey) + Heap Fetches: 0 + -> Parallel Hash (cost=2871.29..2871.29 rows=58229 width=4) (actual time=13.536..13.536 rows=33315 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4960kB + -> Parallel Seq Scan on supplier (cost=0.00..2871.29 rows=58229 width=4) (actual time=2.829..9.918 rows=33315 loops=3) + Filter: ((s_comment)::text !~~ '%Customer%Complaints%'::text) + Rows Removed by Filter: 19 +Planning Time: 0.365 ms +JIT: + Functions: 49 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 1.823 ms, Inlining 0.000 ms, Optimization 0.815 ms, Emission 11.704 ms, Total 14.342 ms +Execution Time: 1365.624 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 + )",15.818475373999945,1.7561404140001287,"Aggregate (cost=5299401.30..5299401.31 rows=1 width=32) (actual time=14423.842..14424.093 rows=1 loops=1) + -> Hash Join (cost=3977031.56..5299354.57 rows=18691 width=8) (actual time=12045.106..14423.787 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=50705.16..1357649.70 rows=60371 width=21) (actual time=173.790..2473.958 rows=61385 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=49705.16..1350612.60 rows=25155 width=21) (actual time=152.765..2574.425 rows=20462 loops=3) + Hash Cond: (l.l_partkey = p.p_partkey) + -> Parallel Seq Scan on lineitem l (cost=0.00..1235310.10 rows=24989410 width=17) (actual time=0.018..1232.670 rows=19995351 loops=3) + -> Parallel Hash (cost=49694.68..49694.68 rows=839 width=4) (actual time=152.324..152.324 rows=681 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 144kB + -> Parallel Seq Scan on part p (cost=0.00..49694.68 rows=839 width=4) (actual time=113.657..152.147 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=3888596.34..3888596.34 rows=1857445 width=36) (actual time=11870.180..11870.226 rows=2000000 loops=1) + Buckets: 131072 Batches: 32 Memory Usage: 4029kB + -> Finalize GroupAggregate (cost=3399438.89..3888596.34 rows=1857445 width=36) (actual time=9576.592..11675.600 rows=2000000 loops=1) + Group Key: lineitem.l_partkey + -> Gather Merge (cost=3399438.89..3832872.99 rows=3714890 width=36) (actual time=9576.538..10185.430 rows=5999325 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3398438.87..3403082.48 rows=1857445 width=36) (actual time=9453.995..9592.532 rows=1999775 loops=3) + Sort Key: lineitem.l_partkey + Sort Method: external merge Disk: 150720kB + Worker 0: Sort Method: external merge Disk: 150720kB + Worker 1: Sort Method: external merge Disk: 150744kB + -> Partial HashAggregate (cost=2836194.18..3103449.45 rows=1857445 width=36) (actual time=6165.258..8853.446 rows=1999775 loops=3) + Group Key: lineitem.l_partkey + Planned Partitions: 128 Batches: 129 Memory Usage: 8209kB Disk Usage: 646888kB + Worker 0: Batches: 129 Memory Usage: 8209kB Disk Usage: 646848kB + Worker 1: Batches: 129 Memory Usage: 8209kB Disk Usage: 978952kB + -> Parallel Seq Scan on lineitem (cost=0.00..1235310.10 rows=24989410 width=9) (actual time=0.013..1279.859 rows=19995351 loops=3) +Planning Time: 2.238 ms +JIT: + Functions: 81 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.888 ms, Inlining 272.435 ms, Optimization 266.639 ms, Emission 174.150 ms, Total 721.112 ms +Execution Time: 14505.023 ms","Aggregate (cost=1362645.77..1362645.78 rows=1 width=8) (actual time=2529.206..2533.262 rows=1 loops=1) + -> Subquery Scan on _t (cost=1353451.27..1362595.45 rows=20124 width=8) (actual time=2505.781..2532.985 rows=5526 loops=1) + Filter: ((_t.l_quantity)::double precision < ('0.2'::double precision * _t._w)) + Rows Removed by Filter: 55859 + -> WindowAgg (cost=1353451.27..1361538.96 rows=60371 width=25) (actual time=2505.776..2528.035 rows=61385 loops=1) + -> Gather Merge (cost=1353451.27..1360482.47 rows=60371 width=17) (actual time=2505.714..2515.549 rows=61385 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1352451.25..1352514.13 rows=25155 width=17) (actual time=2496.305..2497.898 rows=20462 loops=3) + Sort Key: lineitem.l_partkey + Sort Method: quicksort Memory: 1602kB + Worker 0: Sort Method: quicksort Memory: 1893kB + Worker 1: Sort Method: quicksort Memory: 1604kB + -> Parallel Hash Join (cost=49705.16..1350612.60 rows=25155 width=17) (actual time=137.623..2492.097 rows=20462 loops=3) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> Parallel Seq Scan on lineitem (cost=0.00..1235310.10 rows=24989410 width=17) (actual time=0.014..1198.340 rows=19995351 loops=3) + -> Parallel Hash (cost=49694.68..49694.68 rows=839 width=4) (actual time=137.298..137.299 rows=681 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 144kB + -> Parallel Seq Scan on part (cost=0.00..49694.68 rows=839 width=4) (actual time=97.062..137.157 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.206 ms +JIT: + Functions: 44 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 1.543 ms, Inlining 90.669 ms, Optimization 116.079 ms, Emission 83.774 ms, Total 292.066 ms +Execution Time: 2534.136 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",28.767879545999904,24.20113491899997,"Limit (cost=6230431.23..6230431.26 rows=10 width=71) (actual time=31885.351..31885.489 rows=10 loops=1) + -> Sort (cost=6230431.23..6231930.93 rows=599880 width=71) (actual time=31761.319..31761.456 rows=10 loops=1) + Sort Key: o.o_totalprice DESC, o.o_orderdate + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=6089484.08..6217468.04 rows=599880 width=71) (actual time=31564.548..31761.344 rows=624 loops=1) + Group Key: c.c_custkey, o.o_orderkey + -> Incremental Sort (cost=6089484.08..6205470.44 rows=599880 width=44) (actual time=31564.531..31760.875 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=6089483.92..6178475.84 rows=599880 width=44) (actual time=31563.473..31760.314 rows=4368 loops=1) + Merge Cond: (c.c_custkey = o.o_custkey) + -> Index Scan using customer_pkey on customer c (cost=0.43..74745.13 rows=1500026 width=23) (actual time=0.014..150.111 rows=1499744 loops=1) + -> Materialize (cost=6089483.19..6092482.59 rows=599880 width=25) (actual time=31562.945..31563.793 rows=4368 loops=1) + -> Sort (cost=6089483.19..6090982.89 rows=599880 width=25) (actual time=31562.942..31563.462 rows=4368 loops=1) + Sort Key: o.o_custkey + Sort Method: quicksort Memory: 431kB + -> Hash Join (cost=3939370.01..6017558.27 rows=599880 width=25) (actual time=25456.023..31562.617 rows=4368 loops=1) + Hash Cond: (l.l_orderkey = o.o_orderkey) + -> Hash Join (cost=3261827.79..5004424.40 rows=19991484 width=13) (actual time=22785.453..27845.600 rows=4368 loops=1) + Hash Cond: (l.l_orderkey = l2.l_orderkey) + -> Seq Scan on lineitem l (cost=0.00..1585161.84 rows=59974584 width=9) (actual time=0.021..3061.295 rows=59986052 loops=1) + -> Hash (cost=3259952.52..3259952.52 rows=150022 width=4) (actual time=22784.290..22784.421 rows=624 loops=1) + Buckets: 262144 Batches: 1 Memory Usage: 2070kB + -> Finalize GroupAggregate (cost=3141427.54..3259952.52 rows=150022 width=4) (actual time=17761.000..22784.219 rows=624 loops=1) + Group Key: l2.l_orderkey + Filter: (sum(l2.l_quantity) > '300'::numeric) + Rows Removed by Filter: 14999376 + -> Gather Merge (cost=3141427.54..3246450.51 rows=900134 width=36) (actual time=17760.325..19136.302 rows=15008166 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3140427.52..3141552.69 rows=450067 width=36) (actual time=16096.757..16477.051 rows=5002722 loops=3) + Sort Key: l2.l_orderkey + Sort Method: external merge Disk: 325728kB + Worker 0: Sort Method: external merge Disk: 318856kB + Worker 1: Sort Method: external merge Disk: 486432kB + -> Partial HashAggregate (cost=2836194.18..3085857.22 rows=450067 width=36) (actual time=5755.726..14758.696 rows=5002722 loops=3) + Group Key: l2.l_orderkey + Planned Partitions: 32 Batches: 481 Memory Usage: 8345kB Disk Usage: 646152kB + Worker 0: Batches: 521 Memory Usage: 8345kB Disk Usage: 620080kB + Worker 1: Batches: 641 Memory Usage: 8345kB Disk Usage: 947528kB + -> Parallel Seq Scan on lineitem l2 (cost=0.00..1235310.10 rows=24989410 width=9) (actual time=0.010..1258.455 rows=19995351 loops=3) + -> Hash (cost=402172.54..402172.54 rows=14998854 width=20) (actual time=2409.917..2409.917 rows=15000000 loops=1) + Buckets: 131072 Batches: 128 Memory Usage: 7409kB + -> Seq Scan on orders o (cost=0.00..402172.54 rows=14998854 width=20) (actual time=0.010..921.199 rows=15000000 loops=1) +Planning Time: 2.253 ms +JIT: + Functions: 64 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.983 ms, Inlining 106.624 ms, Optimization 160.345 ms, Emission 108.697 ms, Total 378.649 ms +Execution Time: 31977.633 ms","Limit (cost=3954196.18..3954196.20 rows=10 width=71) (actual time=26760.930..26761.030 rows=10 loops=1) + -> Sort (cost=3954196.18..3954569.36 rows=149272 width=71) (actual time=26695.426..26695.525 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=3264478.57..3950970.47 rows=149272 width=71) (actual time=24336.853..26695.353 rows=624 loops=1) + -> Hash Join (cost=3264478.14..3882957.68 rows=149272 width=52) (actual time=24336.830..26693.320 rows=624 loops=1) + Hash Cond: (orders.o_orderkey = _t1.l_orderkey) + -> Seq Scan on orders (cost=0.00..402172.54 rows=14998854 width=20) (actual time=0.019..911.277 rows=15000000 loops=1) + -> Hash (cost=3261445.24..3261445.24 rows=149272 width=36) (actual time=24336.317..24336.413 rows=624 loops=1) + Buckets: 131072 Batches: 2 Memory Usage: 1037kB + -> Subquery Scan on _t1 (cost=3141427.54..3261445.24 rows=149272 width=36) (actual time=19278.341..24336.142 rows=624 loops=1) + -> Finalize GroupAggregate (cost=3141427.54..3259952.52 rows=149272 width=36) (actual time=19278.338..24336.030 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=3141427.54..3246450.51 rows=900134 width=36) (actual time=19277.691..20783.577 rows=15008370 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=3140427.52..3141552.69 rows=450067 width=36) (actual time=18495.573..18864.706 rows=5002790 loops=3) + Sort Key: lineitem.l_orderkey + Sort Method: external merge Disk: 483576kB + Worker 0: Sort Method: external merge Disk: 323488kB + Worker 1: Sort Method: external merge Disk: 323968kB + -> Partial HashAggregate (cost=2836194.18..3085857.22 rows=450067 width=36) (actual time=5832.455..17165.561 rows=5002790 loops=3) + Group Key: lineitem.l_orderkey + Planned Partitions: 32 Batches: 593 Memory Usage: 8345kB Disk Usage: 947384kB + Worker 0: Batches: 481 Memory Usage: 8345kB Disk Usage: 624648kB + Worker 1: Batches: 473 Memory Usage: 8345kB Disk Usage: 630536kB + -> Parallel Seq Scan on lineitem (cost=0.00..1235310.10 rows=24989410 width=9) (actual time=0.018..1315.766 rows=19995351 loops=3) + -> Index Scan using customer_pkey on customer (cost=0.43..0.46 rows=1 width=23) (actual time=0.003..0.003 rows=1 loops=624) + Index Cond: (c_custkey = orders.o_custkey) +Planning Time: 0.253 ms +JIT: + Functions: 49 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.367 ms, Inlining 119.620 ms, Optimization 127.543 ms, Emission 88.111 ms, Total 337.641 ms +Execution Time: 26878.014 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')",2.272854757999994,2.3122276379999676,"Finalize Aggregate (cost=1809942.97..1809942.98 rows=1 width=32) (actual time=2270.312..2276.574 rows=1 loops=1) + -> Gather (cost=1809942.74..1809942.95 rows=2 width=32) (actual time=2270.135..2276.560 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1808942.74..1808942.75 rows=1 width=32) (actual time=2260.574..2260.577 rows=1 loops=3) + -> Parallel Hash Join (cost=72633.36..1808939.34 rows=453 width=12) (actual time=236.174..2260.397 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..1735098.30 rows=460069 width=21) (actual time=0.047..1997.862 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.91..72608.91 rows=1956 width=25) (actual time=226.635..226.635 rows=1585 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 384kB + -> Parallel Seq Scan on part p (cost=0.00..72608.91 rows=1956 width=25) (actual time=164.262..226.248 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.259 ms +JIT: + Functions: 59 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.364 ms, Inlining 95.871 ms, Optimization 230.772 ms, Emission 165.905 ms, Total 495.912 ms +Execution Time: 2277.851 ms","Finalize Aggregate (cost=1809942.97..1809942.98 rows=1 width=32) (actual time=2233.346..2239.154 rows=1 loops=1) + -> Gather (cost=1809942.74..1809942.95 rows=2 width=32) (actual time=2233.167..2239.140 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=1808942.74..1808942.75 rows=1 width=32) (actual time=2223.375..2223.378 rows=1 loops=3) + -> Parallel Hash Join (cost=72633.36..1808939.34 rows=453 width=12) (actual time=242.600..2223.183 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..1735098.30 rows=460069 width=21) (actual time=0.042..1953.703 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.91..72608.91 rows=1956 width=25) (actual time=233.263..233.264 rows=1585 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 384kB + -> Parallel Seq Scan on part (cost=0.00..72608.91 rows=1956 width=25) (actual time=170.877..232.918 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.269 ms +JIT: + Functions: 59 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.476 ms, Inlining 95.413 ms, Optimization 242.869 ms, Emission 174.133 ms, Total 515.891 ms +Execution Time: 2240.486 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",11.367755931000147,6.797240238999848,"Limit (cost=2768544.19..2768627.83 rows=1 width=45) (actual time=7715.524..7753.045 rows=10 loops=1) + -> Nested Loop (cost=2768544.19..2768627.83 rows=1 width=45) (actual time=7593.218..7630.738 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=49) (actual time=13.683..13.780 rows=28 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2907.26..2908.04 rows=309 width=49) (actual time=6.747..6.750 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=49) (actual time=0.020..5.777 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=53) (actual time=0.004..3.728 rows=50000 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.020..0.021 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.014..0.016 rows=1 loops=1) + Filter: ((n_name)::text = 'CANADA'::text) + Rows Removed by Filter: 24 + -> Materialize (cost=2764636.92..2764636.95 rows=3 width=4) (actual time=270.379..271.337 rows=28680 loops=28) + -> Unique (cost=2764636.92..2764636.93 rows=3 width=4) (actual time=7570.607..7575.842 rows=44482 loops=1) + -> Sort (cost=2764636.92..2764636.92 rows=3 width=4) (actual time=7570.605..7572.271 rows=58655 loops=1) + Sort Key: ps.ps_suppkey + Sort Method: quicksort Memory: 1537kB + -> Nested Loop (cost=2556267.38..2764636.89 rows=3 width=4) (actual time=4876.032..7564.752 rows=58655 loops=1) + Join Filter: (ps.ps_partkey = part.p_partkey) + -> Hash Join (cost=2556266.94..2733458.94 rows=49390 width=44) (actual time=4875.986..7344.012 rows=58782 loops=1) + Hash Cond: (lineitem.l_partkey = part.p_partkey) + -> HashAggregate (cost=2505382.88..2669739.77 rows=4889558 width=40) (actual time=4792.311..6964.795 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..1885034.76 rows=9319784 width=13) (actual time=0.029..3044.689 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.56..50631.56 rows=20200 width=4) (actual time=83.609..83.668 rows=21551 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 1014kB + -> Gather (cost=1000.00..50631.56 rows=20200 width=4) (actual time=0.298..80.527 rows=21551 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on part (cost=0.00..47611.56 rows=8417 width=4) (actual time=29.925..72.585 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.004..0.004 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.426 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.186 ms, Inlining 89.441 ms, Optimization 89.621 ms, Emission 67.081 ms, Total 248.330 ms +Execution Time: 7812.408 ms","Limit (cost=1539859.29..1539927.14 rows=1 width=45) (actual time=7442.229..7479.725 rows=10 loops=1) + -> Nested Loop (cost=1539859.29..1539927.14 rows=1 width=45) (actual time=7311.287..7348.782 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=49) (actual time=13.991..14.072 rows=28 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2907.26..2908.04 rows=309 width=49) (actual time=6.634..6.637 rows=14 loops=2) + Sort Key: supplier.s_name NULLS FIRST + Sort Method: quicksort Memory: 399kB + Worker 0: Sort Method: quicksort Memory: 25kB + -> Hash Join (cost=12.39..2894.48 rows=309 width=49) (actual time=0.022..5.662 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=53) (actual time=0.006..3.665 rows=50000 loops=2) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=0.020..0.021 rows=1 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Seq Scan on nation (cost=0.00..12.38 rows=1 width=4) (actual time=0.014..0.015 rows=1 loops=1) + Filter: ((n_name)::text = 'CANADA'::text) + Rows Removed by Filter: 24 + -> Materialize (cost=1535952.02..1535952.03 rows=1 width=4) (actual time=260.246..261.254 rows=28680 loops=28) + -> Group (cost=1535952.02..1535952.02 rows=1 width=4) (actual time=7286.877..7292.518 rows=44482 loops=1) + Group Key: partsupp.ps_suppkey + -> Sort (cost=1535952.02..1535952.02 rows=1 width=4) (actual time=7286.846..7288.584 rows=58655 loops=1) + Sort Key: partsupp.ps_suppkey + Sort Method: quicksort Memory: 1537kB + -> Nested Loop (cost=1488523.06..1535952.01 rows=1 width=4) (actual time=3488.853..7281.571 rows=58655 loops=1) + Join Filter: (partsupp.ps_partkey = part.p_partkey) + -> Merge Join (cost=1488522.63..1527205.69 rows=2962 width=44) (actual time=3488.810..7160.377 rows=58782 loops=1) + Merge Cond: (lineitem.l_partkey = part.p_partkey) + -> Finalize GroupAggregate (cost=1436446.56..1474265.96 rows=293215 width=40) (actual time=3404.404..6906.604 rows=5441655 loops=1) + Group Key: lineitem.l_partkey, lineitem.l_suppkey + -> Gather Merge (cost=1436446.56..1468101.84 rows=249894 width=40) (actual time=3404.393..4960.136 rows=7525096 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1435446.54..1438257.84 rows=124947 width=40) (actual time=3389.489..4386.771 rows=2508369 loops=3) + Group Key: lineitem.l_partkey, lineitem.l_suppkey + -> Sort (cost=1435446.54..1435758.90 rows=124947 width=13) (actual time=3389.451..3619.457 rows=3033053 loops=3) + Sort Key: lineitem.l_partkey, lineitem.l_suppkey + Sort Method: external merge Disk: 59528kB + Worker 0: Sort Method: external merge Disk: 56560kB + Worker 1: Sort Method: external merge Disk: 88880kB + -> Parallel Seq Scan on lineitem (cost=0.00..1422730.68 rows=124947 width=13) (actual time=55.865..2689.890 rows=3033055 loops=3) + Filter: (EXTRACT(year FROM (l_shipdate)::timestamp without time zone) = '1994'::numeric) + Rows Removed by Filter: 16962296 + -> Sort (cost=52076.07..52126.57 rows=20200 width=4) (actual time=84.333..85.365 rows=21551 loops=1) + Sort Key: part.p_partkey + Sort Method: quicksort Memory: 769kB + -> Gather (cost=1000.00..50631.56 rows=20200 width=4) (actual time=0.360..82.725 rows=21551 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on part (cost=0.00..47611.56 rows=8417 width=4) (actual time=30.218..72.731 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.002..0.002 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.423 ms +JIT: + Functions: 88 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.055 ms, Inlining 166.097 ms, Optimization 124.343 ms, Emission 98.584 ms, Total 392.080 ms +Execution Time: 7488.302 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",4.076405424000086,177.5872717870002,"Limit (cost=1758894.07..1758894.08 rows=1 width=27) (actual time=3835.919..3836.173 rows=10 loops=1) + -> Sort (cost=1758894.07..1758894.08 rows=1 width=27) (actual time=3715.858..3716.110 rows=10 loops=1) + Sort Key: (count(*)) DESC, s.s_name + Sort Method: top-N heapsort Memory: 26kB + -> GroupAggregate (cost=1758894.04..1758894.06 rows=1 width=27) (actual time=3712.669..3715.872 rows=4009 loops=1) + Group Key: s.s_name + -> Sort (cost=1758894.04..1758894.05 rows=1 width=19) (actual time=3712.633..3713.923 rows=39448 loops=1) + Sort Key: s.s_name + Sort Method: quicksort Memory: 2769kB + -> Nested Loop (cost=3899.91..1758894.03 rows=1 width=19) (actual time=138.704..3656.192 rows=39448 loops=1) + -> Nested Loop Semi Join (cost=3899.48..1758886.87 rows=1 width=27) (actual time=138.683..3341.821 rows=81045 loops=1) + -> Gather (cost=3898.91..1758677.94 rows=1 width=27) (actual time=138.669..2912.412 rows=135716 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Nested Loop Anti Join (cost=2898.91..1757677.84 rows=1 width=27) (actual time=128.598..3390.951 rows=45239 loops=3) + -> Parallel Hash Join (cost=2898.35..1332174.22 rows=43517 width=27) (actual time=128.516..2600.292 rows=507455 loops=3) + Hash Cond: (l1.l_suppkey = s.s_suppkey) + -> Parallel Seq Scan on lineitem l1 (cost=0.00..1297783.62 rows=8329803 width=8) (actual time=0.035..1629.906 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=128.311..128.314 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=81.846..86.817 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.009..3.109 rows=33333 loops=3) + -> Hash (cost=12.38..12.38 rows=1 width=4) (actual time=81.818..81.820 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=81.810..81.811 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..209.24 rows=44 width=8) (actual time=0.001..0.001 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..208.91 rows=133 width=8) (actual time=0.003..0.003 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.004..0.004 rows=0 loops=81045) + Index Cond: (o_orderkey = l1.l_orderkey) + Filter: (o_orderstatus = 'F'::bpchar) + Rows Removed by Filter: 1 +Planning Time: 1.058 ms +JIT: + Functions: 105 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.954 ms, Inlining 72.641 ms, Optimization 171.271 ms, Emission 121.627 ms, Total 368.492 ms +Execution Time: 3837.613 ms","Limit (cost=57429700.90..57429700.93 rows=10 width=44) (actual time=194894.532..194894.545 rows=10 loops=1) + CTE _t5 + -> Seq Scan on lineitem lineitem_2 (cost=0.00..1735098.30 rows=19991528 width=20) (actual time=0.013..4470.049 rows=37929348 loops=1) + Filter: (l_commitdate < l_receiptdate) + Rows Removed by Filter: 22056704 + -> Sort (cost=55694602.60..55694603.92 rows=526 width=44) (actual time=194706.374..194706.385 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=55688319.20..55694591.24 rows=526 width=44) (actual time=194618.676..194706.071 rows=4010 loops=1) + Group Key: supplier.s_suppkey + -> Merge Left Join (cost=55688319.20..55694582.03 rows=526 width=27) (actual time=194618.610..194703.844 rows=39449 loops=1) + Merge Cond: (supplier.s_suppkey = _t3.anything_l_suppkey) + -> Nested Loop (cost=0.29..6260.93 rows=526 width=23) (actual time=0.049..21.944 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..4748.55 rows=100000 width=27) (actual time=0.014..8.293 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.011..0.012 rows=1 loops=1) + Filter: ((n_name)::text = 'SAUDI ARABIA'::text) + Rows Removed by Filter: 24 + -> Sort (cost=55688318.91..55688319.34 rows=175 width=4) (actual time=194618.476..194653.754 rows=990375 loops=1) + Sort Key: _t3.anything_l_suppkey + Sort Method: external sort Disk: 15552kB + -> Hash Right Anti Join (cost=55687174.26..55688312.39 rows=175 width=4) (actual time=189670.321..194470.725 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=21649829.18..21650229.18 rows=40000 width=8) (actual time=41337.479..60009.842 rows=34557064 loops=1) + Group Key: _t6.l_linenumber, _t6.l_orderkey + Batches: 1925 Memory Usage: 10033kB Disk Usage: 2747312kB + -> Hash Join (cost=2063084.40..17209854.41 rows=887994953 width=8) (actual time=7062.153..32209.921 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..399830.56 rows=19991528 width=12) (actual time=0.306..5725.065 rows=37929348 loops=1) + -> Hash (cost=1735098.30..1735098.30 rows=19991528 width=8) (actual time=7056.462..7056.463 rows=37929348 loops=1) + Buckets: 262144 (originally 262144) Batches: 256 (originally 128) Memory Usage: 7825kB + -> Seq Scan on lineitem (cost=0.00..1735098.30 rows=19991528 width=8) (actual time=0.041..4295.807 rows=37929348 loops=1) + Filter: (l_commitdate < l_receiptdate) + Rows Removed by Filter: 22056704 + -> Hash (cost=34037341.59..34037341.59 rows=200 width=16) (actual time=126600.456..126600.461 rows=17654363 loops=1) + Buckets: 262144 (originally 1024) Batches: 256 (originally 1) Memory Usage: 6145kB + -> Subquery Scan on _t3 (cost=34036839.59..34037341.59 rows=200 width=16) (actual time=78111.092..124916.483 rows=17654363 loops=1) + -> HashAggregate (cost=34036839.59..34037339.59 rows=200 width=48) (actual time=78111.089..124043.663 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=3960512.68..7396990.99 rows=2663984860 width=18) (actual time=19320.708..61269.887 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..399830.56 rows=19991528 width=12) (actual time=0.015..9502.706 rows=37929348 loops=1) + -> Hash (cost=2917985.38..2917985.38 rows=59974584 width=14) (actual time=19312.435..19312.437 rows=59986052 loops=1) + Buckets: 262144 Batches: 512 Memory Usage: 7555kB + -> Hash Join (cost=648248.22..2917985.38 rows=59974584 width=14) (actual time=1943.050..14539.904 rows=59986052 loops=1) + Hash Cond: (lineitem_1.l_orderkey = orders.o_orderkey) + -> Seq Scan on lineitem lineitem_1 (cost=0.00..1585161.84 rows=59974584 width=8) (actual time=0.002..3430.426 rows=59986052 loops=1) + -> Hash (cost=402172.54..402172.54 rows=14998854 width=6) (actual time=1941.148..1941.149 rows=15000000 loops=1) + Buckets: 262144 Batches: 128 Memory Usage: 6391kB + -> Seq Scan on orders (cost=0.00..402172.54 rows=14998854 width=6) (actual time=0.014..895.708 rows=15000000 loops=1) +Planning Time: 0.475 ms +JIT: + Functions: 80 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.408 ms, Inlining 20.963 ms, Optimization 130.071 ms, Emission 92.415 ms, Total 245.857 ms +Execution Time: 195265.510 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.2176035910001701,2.648717250000118,"Finalize GroupAggregate (cost=474350.72..475324.30 rows=7492 width=72) (actual time=1012.225..1018.525 rows=7 loops=1) + Group Key: (SUBSTRING(c.c_phone FROM 1 FOR 2)) + InitPlan 1 (returns $1) + -> Finalize Aggregate (cost=51637.98..51637.99 rows=1 width=32) (actual time=130.124..130.208 rows=1 loops=1) + -> Gather (cost=51637.76..51637.97 rows=2 width=32) (actual time=129.994..130.170 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=50637.76..50637.77 rows=1 width=32) (actual time=120.888..120.889 rows=1 loops=3) + -> Parallel Seq Scan on customer c2 (cost=0.00..50588.01 rows=19900 width=6) (actual time=5.024..113.279 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=422712.73..423511.49 rows=6244 width=72) (actual time=1012.199..1018.412 rows=7 loops=1) + Workers Planned: 2 + Params Evaluated: $1 + Workers Launched: 2 + -> Partial GroupAggregate (cost=421712.70..421790.75 rows=3122 width=72) (actual time=851.635..853.459 rows=2 loops=3) + Group Key: (SUBSTRING(c.c_phone FROM 1 FOR 2)) + -> Sort (cost=421712.70..421720.51 rows=3122 width=38) (actual time=851.345..852.105 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: 25kB + Worker 1: Sort Method: quicksort Memory: 4028kB + -> Parallel Hash Right Anti Join (cost=50679.16..421531.50 rows=3122 width=38) (actual time=846.050..848.899 rows=21305 loops=3) + Hash Cond: (o.o_custkey = c.c_custkey) + -> Parallel Seq Scan on orders o (cost=0.00..314679.22 rows=6249522 width=4) (actual time=0.015..319.471 rows=5000000 loops=3) + -> Parallel Hash (cost=50588.01..50588.01 rows=7292 width=26) (actual time=107.487..107.488 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.01 rows=7292 width=26) (actual time=4.258..92.553 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.225 ms +JIT: + Functions: 71 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 2.963 ms, Inlining 0.000 ms, Optimization 1.528 ms, Emission 26.323 ms, Total 30.814 ms +Execution Time: 1019.695 ms","GroupAggregate (cost=1106459.00..1106677.75 rows=8750 width=72) (actual time=2882.504..2887.290 rows=7 loops=1) + Group Key: (SUBSTRING(customer.c_phone FROM 1 FOR 2)) + -> Sort (cost=1106459.00..1106480.88 rows=8750 width=38) (actual time=2881.714..2883.742 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=1080565.35..1105886.09 rows=8750 width=38) (actual time=2842.040..2875.779 rows=63914 loops=1) + Hash Cond: (orders.o_custkey = customer.c_custkey) + -> Finalize HashAggregate (cost=972776.77..994758.69 rows=857831 width=4) (actual time=2106.750..2362.126 rows=999982 loops=1) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 81 Memory Usage: 9361kB Disk Usage: 64472kB + -> Gather (cost=651591.03..880559.93 rows=1715662 width=4) (actual time=1281.154..1786.972 rows=2936007 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=650591.03..707993.73 rows=857831 width=4) (actual time=1269.484..1733.745 rows=978669 loops=3) + Group Key: orders.o_custkey + Planned Partitions: 16 Batches: 81 Memory Usage: 10385kB Disk Usage: 129464kB + Worker 0: Batches: 81 Memory Usage: 10385kB Disk Usage: 178456kB + Worker 1: Batches: 81 Memory Usage: 10385kB Disk Usage: 129128kB + -> Parallel Seq Scan on orders (cost=0.00..314679.22 rows=6249522 width=4) (actual time=0.016..327.491 rows=5000000 loops=3) + -> Hash (cost=107569.84..107569.84 rows=17500 width=26) (actual time=396.216..396.298 rows=190691 loops=1) + Buckets: 131072 (originally 32768) Batches: 2 (originally 1) Memory Usage: 7169kB + -> Nested Loop (cost=52637.98..107569.84 rows=17500 width=26) (actual time=216.166..379.460 rows=190691 loops=1) + Join Filter: ((avg((customer_1.c_acctbal)::numeric)) < customer.c_acctbal) + Rows Removed by Join Filter: 229283 + -> Finalize Aggregate (cost=51637.98..51637.99 rows=1 width=32) (actual time=215.921..215.961 rows=1 loops=1) + -> Gather (cost=51637.76..51637.97 rows=2 width=32) (actual time=215.817..215.947 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=50637.76..50637.77 rows=1 width=32) (actual time=205.779..205.780 rows=1 loops=3) + -> Parallel Seq Scan on customer customer_1 (cost=0.00..50588.01 rows=19900 width=6) (actual time=95.321..198.904 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..55275.58 rows=52501 width=26) (actual time=0.235..138.905 rows=419974 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Seq Scan on customer (cost=0.00..49025.48 rows=21875 width=26) (actual time=40.903..138.704 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.209 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.148 ms, Inlining 244.784 ms, Optimization 158.554 ms, Emission 126.749 ms, Total 533.235 ms +Execution Time: 2912.064 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",1.6544156660002045,2.4787433420001435,"Limit (cost=115430.49..115430.51 rows=10 width=17) (actual time=826.123..826.341 rows=10 loops=1) + CTE customer_total_return + -> Finalize GroupAggregate (cost=83002.14..84747.00 rows=13804 width=48) (actual time=193.872..496.538 rows=539331 loops=1) + Group Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + -> Gather Merge (cost=83002.14..84459.41 rows=11504 width=48) (actual time=193.861..328.799 rows=543114 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=82002.12..82131.54 rows=5752 width=48) (actual time=179.026..245.386 rows=181038 loops=3) + Group Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + -> Sort (cost=82002.12..82016.50 rows=5752 width=22) (actual time=178.995..192.471 rows=185902 loops=3) + Sort Key: store_returns.sr_customer_sk, store_returns.sr_store_sk + Sort Method: external merge Disk: 7616kB + Worker 0: Sort Method: external merge Disk: 5072kB + Worker 1: Sort Method: external merge Disk: 5080kB + -> Parallel Hash Join (cost=2571.80..81642.91 rows=5752 width=22) (actual time=5.696..142.649 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.24 rows=1198924 width=30) (actual time=0.019..68.344 rows=959177 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=1.469..1.469 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=2.259..4.339 rows=366 loops=1) + Filter: (d_year = 2000) + Rows Removed by Filter: 72683 + -> Sort (cost=30683.49..30685.27 rows=713 width=17) (actual time=816.200..816.203 rows=10 loops=1) + Sort Key: customer.c_customer_id + Sort Method: top-N heapsort Memory: 25kB + -> Hash Join (cost=26897.26..30668.08 rows=713 width=17) (actual time=709.595..811.491 rows=45702 loops=1) + Hash Cond: (ctr1.ctr_customer_sk = customer.c_customer_sk) + -> Hash Join (cost=357.26..694.28 rows=713 width=8) (actual time=632.053..713.340 rows=45719 loops=1) + Hash Cond: (ctr1.ctr_store_sk = store.s_store_sk) + -> Hash Join (cost=350.60..663.23 rows=4601 width=24) (actual time=632.005..706.082 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..276.08 rows=13804 width=48) (actual time=193.874..216.715 rows=539331 loops=1) + -> Hash (cost=348.10..348.10 rows=200 width=40) (actual time=438.102..438.103 rows=51 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 11kB + -> HashAggregate (cost=345.10..348.10 rows=200 width=40) (actual time=438.077..438.089 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..276.08 rows=13804 width=40) (actual time=0.001..379.805 rows=539331 loops=1) + -> Hash (cost=6.28..6.28 rows=31 width=8) (actual time=0.038..0.039 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.011..0.035 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=77.327..77.328 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.015..35.594 rows=500000 loops=1) +Planning Time: 0.250 ms +JIT: + Functions: 90 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 2.852 ms, Inlining 0.000 ms, Optimization 1.349 ms, Emission 20.903 ms, Total 25.105 ms +Execution Time: 830.795 ms","Limit (cost=582114.77..582114.80 rows=10 width=17) (actual time=3572.753..3572.771 rows=10 loops=1) + CTE _s0 + -> Seq Scan on store_returns store_returns_1 (cost=0.00..91326.17 rows=2877417 width=30) (actual time=0.007..212.830 rows=2877532 loops=1) + CTE _t3 + -> Seq Scan on store (cost=0.00..6.28 rows=31 width=11) (actual time=0.010..0.044 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=363 width=16) (actual time=1.728..3.385 rows=366 loops=1) + Filter: (d_year = 2000) + Rows Removed by Filter: 72683 + -> Sort (cost=487837.21..487837.25 rows=14 width=17) (actual time=3230.931..3230.945 rows=10 loops=1) + Sort Key: customer.c_customer_id NULLS FIRST + Sort Method: top-N heapsort Memory: 25kB + -> Hash Join (cost=469089.81..487836.95 rows=14 width=17) (actual time=3165.727..3225.683 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.017..30.752 rows=500000 loops=1) + -> Hash (cost=469089.63..469089.63 rows=14 width=16) (actual time=3165.678..3165.691 rows=47280 loops=1) + Buckets: 65536 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2729kB + -> Nested Loop (cost=361984.13..469089.63 rows=14 width=16) (actual time=2147.644..3162.917 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.26 rows=363 width=8) (actual time=1.731..1.762 rows=366 loops=1) + -> Materialize (cost=361984.13..468657.86 rows=78 width=24) (actual time=5.863..7.364 rows=51346 loops=366) + -> Nested Loop (cost=361984.13..468657.47 rows=78 width=24) (actual time=2145.779..2223.366 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.011..0.015 rows=31 loops=1) + -> Materialize (cost=361984.13..468423.29 rows=505 width=48) (actual time=43.759..70.402 rows=51346 loops=31) + -> Hash Join (cost=361984.13..468420.76 rows=505 width=48) (actual time=1356.542..2134.341 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=181188.56..287621.17 rows=1514 width=72) (actual time=442.846..1188.597 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..91326.17 rows=2877417 width=24) (actual time=0.012..180.489 rows=2877532 loops=1) + -> Hash (cost=180588.56..180588.56 rows=40000 width=48) (actual time=442.768..442.773 rows=177510 loops=1) + Buckets: 262144 (originally 65536) Batches: 2 (originally 1) Memory Usage: 7165kB + -> Subquery Scan on _s9 (cost=168621.32..180588.56 rows=40000 width=48) (actual time=357.458..427.584 rows=177527 loops=1) + -> HashAggregate (cost=168621.32..180188.56 rows=40000 width=48) (actual time=357.455..418.868 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.80..102091.36 rows=809490 width=30) (actual time=0.072..327.404 rows=181937 loops=1) + Hash Cond: (_s4.sr_returned_date_sk = _t7.d_date_sk) + -> Hash Join (cost=1.01..72799.66 rows=446000 width=38) (actual time=0.029..282.686 rows=924363 loops=1) + Hash Cond: (_s4.sr_store_sk = _t6.s_store_sk) + -> CTE Scan on _s0 _s4 (cost=0.00..57548.34 rows=2877417 width=38) (actual time=0.013..124.552 rows=2877532 loops=1) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=0.008..0.009 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.003..0.005 rows=31 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=0.036..0.037 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 _t7 (cost=0.00..7.26 rows=363 width=8) (actual time=0.002..0.016 rows=366 loops=1) + -> Hash (cost=180793.06..180793.06 rows=200 width=40) (actual time=913.683..913.689 rows=17 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Subquery Scan on _s8 (cost=180788.56..180793.06 rows=200 width=40) (actual time=913.672..913.681 rows=17 loops=1) + -> HashAggregate (cost=180788.56..180791.06 rows=200 width=40) (actual time=913.669..913.677 rows=17 loops=1) + Group Key: _s0.sr_store_sk + Batches: 1 Memory Usage: 40kB + -> HashAggregate (cost=168621.32..180188.56 rows=40000 width=48) (actual time=840.584..903.454 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.80..102091.36 rows=809490 width=30) (actual time=1.780..806.247 rows=181937 loops=1) + Hash Cond: (_s0.sr_returned_date_sk = _t4.d_date_sk) + -> Hash Join (cost=1.01..72799.66 rows=446000 width=38) (actual time=0.061..755.861 rows=924363 loops=1) + Hash Cond: (_s0.sr_store_sk = _t3.s_store_sk) + -> CTE Scan on _s0 (cost=0.00..57548.34 rows=2877417 width=38) (actual time=0.008..580.685 rows=2877532 loops=1) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=0.045..0.046 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.002..0.040 rows=31 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=1.712..1.713 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 (cost=0.00..7.26 rows=363 width=8) (actual time=0.002..1.692 rows=366 loops=1) +Planning Time: 0.772 ms +JIT: + Functions: 103 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.484 ms, Inlining 19.345 ms, Optimization 217.270 ms, Emission 149.597 ms, Total 388.697 ms +Execution Time: 3589.358 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.46529945400016,18.630681193999862,"Limit (cost=2050444.91..2050456.80 rows=1 width=232) (actual time=14988.097..14991.788 rows=10 loops=1) + CTE wswscs + -> Finalize GroupAggregate (cost=2040334.91..2043842.86 rows=10445 width=232) (actual time=14669.162..14673.715 rows=263 loops=1) + Group Key: date_dim_2.d_week_seq + -> Gather Merge (cost=2040334.91..2042772.25 rows=20890 width=232) (actual time=14669.140..14672.913 rows=789 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=2039334.89..2039361.00 rows=10445 width=232) (actual time=14655.505..14655.520 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=1932878.95..2038637.66 rows=10445 width=232) (actual time=14655.098..14655.434 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..993479.74 rows=9000232 width=22) (actual time=132.053..13375.200 rows=7175008 loops=3) + Hash Cond: (catalog_sales.cs_sold_date_sk = date_dim_2.d_date_sk) + -> Parallel Append (cost=0.00..903787.49 rows=9000233 width=14) (actual time=126.736..12645.293 rows=7199609 loops=3) + -> Parallel Seq Scan on catalog_sales (cost=0.00..571766.37 rows=6001437 width=14) (actual time=64.828..7719.891 rows=4800420 loops=3) + -> Parallel Seq Scan on web_sales (cost=0.00..287019.96 rows=2998796 width=14) (actual time=95.146..6868.348 rows=3598783 loops=2) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=4.862..4.863 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5280kB + -> Parallel Seq Scan on date_dim date_dim_2 (cost=0.00..2461.70 rows=42970 width=24) (actual time=0.017..6.064 rows=73049 loops=1) + -> Merge Join (cost=6602.05..6613.93 rows=1 width=232) (actual time=14676.274..14676.300 rows=10 loops=1) + Merge Cond: (y.d_week_seq1 = ((z.d_week_seq2 - 53))) + -> Subquery Scan on y (cost=3295.12..3306.92 rows=2 width=232) (actual time=14673.230..14673.242 rows=10 loops=1) + Filter: (y.rn1 = 1) + -> WindowAgg (cost=3295.12..3302.38 rows=363 width=240) (actual time=14673.227..14673.238 rows=10 loops=1) + Run Condition: (row_number() OVER (?) <= 1) + -> Sort (cost=3295.12..3296.03 rows=363 width=232) (actual time=14673.218..14673.222 rows=58 loops=1) + Sort Key: wswscs.d_week_seq, wswscs.sun_sales DESC + Sort Method: quicksort Memory: 59kB + -> Hash Join (cost=2949.65..3279.69 rows=363 width=232) (actual time=14672.723..14673.139 rows=365 loops=1) + Hash Cond: (wswscs.d_week_seq = date_dim.d_week_seq) + -> CTE Scan on wswscs (cost=0.00..208.90 rows=10445 width=232) (actual time=14669.165..14670.104 rows=263 loops=1) + -> Hash (cost=2945.11..2945.11 rows=363 width=8) (actual time=2.974..2.975 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=363 width=8) (actual time=1.488..2.951 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + -> Sort (cost=3306.93..3306.93 rows=2 width=232) (actual time=3.028..3.030 rows=10 loops=1) + Sort Key: ((z.d_week_seq2 - 53)) + Sort Method: quicksort Memory: 30kB + -> Subquery Scan on z (cost=3295.12..3306.92 rows=2 width=232) (actual time=2.974..3.016 rows=53 loops=1) + Filter: (z.rn2 = 1) + -> WindowAgg (cost=3295.12..3302.38 rows=363 width=240) (actual time=2.970..3.008 rows=53 loops=1) + Run Condition: (row_number() OVER (?) <= 1) + -> Sort (cost=3295.12..3296.03 rows=363 width=232) (actual time=2.963..2.974 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.65..3279.69 rows=363 width=232) (actual time=2.879..2.897 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.90 rows=10445 width=232) (actual time=0.000..0.009 rows=263 loops=1) + -> Hash (cost=2945.11..2945.11 rows=363 width=8) (actual time=2.852..2.853 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=363 width=8) (actual time=1.504..2.830 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 +Planning Time: 0.286 ms +JIT: + Functions: 94 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.441 ms, Inlining 99.595 ms, Optimization 344.063 ms, Emission 247.646 ms, Total 695.745 ms +Execution Time: 14994.366 ms","Limit (cost=24217331.63..24217379.96 rows=10 width=232) (actual time=19124.929..19125.198 rows=10 loops=1) + CTE _t1 + -> Seq Scan on date_dim date_dim_2 (cost=0.00..3127.73 rows=1421 width=16) (actual time=1.812..3.550 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=1421 width=32) (actual time=1.376..2.466 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..655786.48 rows=14403448 width=14) (actual time=0.266..6039.805 rows=14401261 loops=1) + CTE _s5 + -> Seq Scan on web_sales (cost=0.00..329003.10 rows=7197110 width=14) (actual time=0.255..2872.446 rows=7197566 loops=1) + -> Merge Join (cost=23226286.58..23229384.59 rows=641 width=232) (actual time=18547.784..18548.048 rows=10 loops=1) + Merge Cond: (_t1.d_week_seq = date_dim_1.d_week_seq) + -> Nested Loop (cost=23223309.03..23226296.99 rows=358 width=904) (actual time=18545.549..18545.771 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=23220348.48..23222265.08 rows=200 width=912) (actual time=18540.754..18542.101 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=19351945.62..19353257.18 rows=200 width=688) (actual time=17160.244..17161.174 rows=62 loops=1) + Join Filter: (_t1_1.d_week_seq = _s15.d_week_seq) + Rows Removed by Join Filter: 5169 + -> Nested Loop (cost=11610226.18..11610932.71 rows=200 width=464) (actual time=14651.164..14651.605 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=11610194.21..11610201.71 rows=200 width=456) (actual time=14650.998..14651.055 rows=62 loops=1) + Merge Cond: (_t1.d_week_seq = _s7.d_week_seq) + -> Merge Left Join (cost=7741776.20..7741780.20 rows=200 width=232) (actual time=9738.248..9738.280 rows=62 loops=1) + Merge Cond: (_t1.d_week_seq = _s3.d_week_seq) + -> Sort (cost=41.62..42.12 rows=200 width=8) (actual time=3.831..3.835 rows=62 loops=1) + Sort Key: _t1.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> HashAggregate (cost=31.97..33.97 rows=200 width=8) (actual time=3.795..3.806 rows=210 loops=1) + Group Key: _t1.d_week_seq + Batches: 1 Memory Usage: 48kB + -> CTE Scan on _t1 (cost=0.00..28.42 rows=1421 width=8) (actual time=1.815..3.681 rows=1461 loops=1) + -> Sort (cost=7741734.58..7741735.08 rows=200 width=232) (actual time=9734.406..9734.418 rows=62 loops=1) + Sort Key: _s3.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 39kB + -> Subquery Scan on _s3 (cost=7741719.44..7741726.94 rows=200 width=232) (actual time=9734.255..9734.382 rows=159 loops=1) + -> HashAggregate (cost=7741719.44..7741724.94 rows=200 width=232) (actual time=9734.252..9734.370 rows=159 loops=1) + Group Key: _t3.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=46.18..3904100.76 rows=102336498 width=60) (actual time=3.057..8634.615 rows=8627065 loops=1) + Hash Cond: (_s1.cs_sold_date_sk = _t3.d_date_sk) + -> CTE Scan on _s1 (cost=0.00..288068.96 rows=14403448 width=22) (actual time=0.266..7686.840 rows=14401261 loops=1) + -> Hash (cost=28.42..28.42 rows=1421 width=54) (actual time=2.742..2.743 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 (cost=0.00..28.42 rows=1421 width=54) (actual time=1.378..2.650 rows=1461 loops=1) + -> Sort (cost=3868418.01..3868418.51 rows=200 width=232) (actual time=4912.739..4912.750 rows=62 loops=1) + Sort Key: _s7.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 39kB + -> Subquery Scan on _s7 (cost=3868402.86..3868410.36 rows=200 width=232) (actual time=4912.634..4912.707 rows=158 loops=1) + -> HashAggregate (cost=3868402.86..3868408.36 rows=200 width=232) (actual time=4912.631..4912.695 rows=158 loops=1) + Group Key: _t5.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=46.18..1950822.85 rows=51135467 width=60) (actual time=0.431..4286.590 rows=4334472 loops=1) + Hash Cond: (_s5.ws_sold_date_sk = _t5.d_date_sk) + -> CTE Scan on _s5 (cost=0.00..143942.20 rows=7197110 width=22) (actual time=0.256..3752.974 rows=7197566 loops=1) + -> Hash (cost=28.42..28.42 rows=1421 width=54) (actual time=0.161..0.161 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t5 (cost=0.00..28.42 rows=1421 width=54) (actual time=0.004..0.064 rows=1461 loops=1) + -> Materialize (cost=31.97..34.97 rows=200 width=8) (actual time=0.003..0.006 rows=116 loops=62) + -> HashAggregate (cost=31.97..33.97 rows=200 width=8) (actual time=0.156..0.174 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..28.42 rows=1421 width=8) (actual time=0.001..0.051 rows=1461 loops=1) + -> Materialize (cost=7741719.44..7741727.94 rows=200 width=232) (actual time=40.469..40.473 rows=84 loops=62) + -> Subquery Scan on _s15 (cost=7741719.44..7741726.94 rows=200 width=232) (actual time=2509.070..2509.201 rows=157 loops=1) + -> HashAggregate (cost=7741719.44..7741724.94 rows=200 width=232) (actual time=2509.067..2509.189 rows=157 loops=1) + Group Key: _t9.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=46.18..3904100.76 rows=102336498 width=60) (actual time=0.207..1473.792 rows=8627065 loops=1) + Hash Cond: (_s13.cs_sold_date_sk = _t9.d_date_sk) + -> CTE Scan on _s1 _s13 (cost=0.00..288068.96 rows=14403448 width=22) (actual time=0.018..599.466 rows=14401261 loops=1) + -> Hash (cost=28.42..28.42 rows=1421 width=54) (actual time=0.168..0.169 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t9 (cost=0.00..28.42 rows=1421 width=54) (actual time=0.003..0.064 rows=1461 loops=1) + -> Materialize (cost=3868402.86..3868411.36 rows=200 width=232) (actual time=22.266..22.270 rows=84 loops=62) + -> Subquery Scan on _s19 (cost=3868402.86..3868410.36 rows=200 width=232) (actual time=1380.499..1380.568 rows=156 loops=1) + -> HashAggregate (cost=3868402.86..3868408.36 rows=200 width=232) (actual time=1380.496..1380.557 rows=156 loops=1) + Group Key: _t11.d_week_seq + Batches: 1 Memory Usage: 544kB + -> Hash Join (cost=46.18..1950822.85 rows=51135467 width=60) (actual time=0.191..790.263 rows=4334472 loops=1) + Hash Cond: (_s17.ws_sold_date_sk = _t11.d_date_sk) + -> CTE Scan on _s5 _s17 (cost=0.00..143942.20 rows=7197110 width=22) (actual time=0.015..304.937 rows=7197566 loops=1) + -> Hash (cost=28.42..28.42 rows=1421 width=54) (actual time=0.161..0.161 rows=1461 loops=1) + Buckets: 2048 Batches: 1 Memory Usage: 101kB + -> CTE Scan on _t3 _t11 (cost=0.00..28.42 rows=1421 width=54) (actual time=0.008..0.067 rows=1461 loops=1) + -> Materialize (cost=2960.55..2964.15 rows=358 width=8) (actual time=0.056..0.058 rows=45 loops=62) + -> Group (cost=2960.55..2962.36 rows=358 width=8) (actual time=3.485..3.517 rows=53 loops=1) + Group Key: date_dim.d_week_seq + -> Sort (cost=2960.55..2961.45 rows=363 width=8) (actual time=3.480..3.497 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=363 width=8) (actual time=1.782..3.455 rows=365 loops=1) + Filter: ((d_week_seq IS NOT NULL) AND (d_year = 2002)) + Rows Removed by Filter: 72684 + -> Sort (cost=2977.55..2978.44 rows=358 width=8) (actual time=2.208..2.209 rows=10 loops=1) + Sort Key: date_dim_1.d_week_seq NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> Group (cost=2960.55..2962.36 rows=358 width=8) (actual time=2.177..2.201 rows=53 loops=1) + Group Key: date_dim_1.d_week_seq + -> Sort (cost=2960.55..2961.45 rows=363 width=8) (actual time=2.174..2.184 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=363 width=8) (actual time=1.093..2.160 rows=365 loops=1) + Filter: ((d_week_seq IS NOT NULL) AND (d_year = 2001)) + Rows Removed by Filter: 72684 +Planning Time: 1.201 ms +JIT: + Functions: 132 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.216 ms, Inlining 7.964 ms, Optimization 325.339 ms, Emission 244.060 ms, Total 581.579 ms +Execution Time: 19196.066 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",15.967335601000286,16.69006664499966,"Limit (cost=40603.37..197657.20 rows=100 width=65) (actual time=21618.932..21703.211 rows=100 loops=1) + -> Incremental Sort (cost=40603.37..3096870.92 rows=1946 width=65) (actual time=21611.365..21695.638 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=25245.38..3096810.66 rows=1946 width=65) (actual time=21527.034..21695.531 rows=141 loops=1) + Group Key: dt.d_year, item.i_brand, item.i_brand_id + -> Incremental Sort (cost=25245.38..3096766.88 rows=1946 width=39) (actual time=21527.010..21695.241 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=9810.75..3096706.61 rows=1946 width=39) (actual time=21442.963..21693.518 rows=4885 loops=1) + Join Filter: (dt.d_date_sk = store_sales.ss_sold_date_sk) + Rows Removed by Join Filter: 156946182 + -> Gather Merge (cost=3775.03..4452.70 rows=5946 width=16) (actual time=13.495..13.913 rows=3031 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2775.02..2783.77 rows=3498 width=16) (actual time=2.815..2.906 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=3498 width=16) (actual time=0.020..2.634 rows=3000 loops=2) + Filter: (d_moy = 11) + Rows Removed by Filter: 33524 + -> Materialize (cost=6035.71..851239.60 rows=25127 width=39) (actual time=0.025..5.666 rows=51782 loops=3031) + -> Gather (cost=6035.71..851113.96 rows=25127 width=39) (actual time=75.710..13257.967 rows=51799 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5035.71..847601.26 rows=10470 width=39) (actual time=66.464..13251.052 rows=17266 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797525.83 rows=11998983 width=22) (actual time=0.231..12754.082 rows=9600330 loops=3) + -> Parallel Hash (cost=5035.25..5035.25 rows=37 width=33) (actual time=65.458..65.459 rows=60 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=37 width=33) (actual time=5.090..65.418 rows=60 loops=3) + Filter: (i_manufact_id = 128) + Rows Removed by Filter: 33940 +Planning Time: 0.182 ms +JIT: + Functions: 57 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 2.810 ms, Inlining 0.000 ms, Optimization 1.290 ms, Emission 17.343 ms, Total 21.442 ms +Execution Time: 21704.755 ms","Limit (cost=40603.37..197657.20 rows=100 width=65) (actual time=22029.957..22117.702 rows=100 loops=1) + -> Incremental Sort (cost=40603.37..3096870.92 rows=1946 width=65) (actual time=22022.557..22110.297 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=25245.38..3096810.66 rows=1946 width=65) (actual time=21934.670..22110.185 rows=141 loops=1) + Group Key: date_dim.d_year, item.i_brand_id, item.i_brand + -> Incremental Sort (cost=25245.38..3096766.88 rows=1946 width=39) (actual time=21934.648..22109.891 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=9810.75..3096706.61 rows=1946 width=39) (actual time=21847.099..22109.249 rows=4885 loops=1) + Join Filter: (store_sales.ss_sold_date_sk = date_dim.d_date_sk) + Rows Removed by Join Filter: 156946444 + -> Gather Merge (cost=3775.03..4452.70 rows=5946 width=16) (actual time=13.207..13.633 rows=3031 loops=1) + Workers Planned: 1 + Workers Launched: 1 + -> Sort (cost=2775.02..2783.77 rows=3498 width=16) (actual time=2.762..2.857 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=3498 width=16) (actual time=0.020..2.581 rows=3000 loops=2) + Filter: (d_moy = 11) + Rows Removed by Filter: 33524 + -> Materialize (cost=6035.71..851239.60 rows=25127 width=39) (actual time=0.033..5.674 rows=51782 loops=3031) + -> Gather (cost=6035.71..851113.96 rows=25127 width=39) (actual time=99.487..13276.518 rows=51799 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5035.71..847601.26 rows=10470 width=39) (actual time=90.847..13270.410 rows=17266 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Seq Scan on store_sales (cost=0.00..797525.83 rows=11998983 width=22) (actual time=0.242..12753.964 rows=9600330 loops=3) + -> Parallel Hash (cost=5035.25..5035.25 rows=37 width=33) (actual time=89.043..89.043 rows=60 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=37 width=33) (actual time=4.740..88.985 rows=60 loops=3) + Filter: (i_manufact_id = 128) + Rows Removed by Filter: 33940 +Planning Time: 0.177 ms +JIT: + Functions: 57 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 2.700 ms, Inlining 0.000 ms, Optimization 1.245 ms, Emission 17.508 ms, Total 21.453 ms +Execution Time: 22119.546 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",13.90106039200009,13.93478659099992,"Limit (cost=878246.50..878246.52 rows=10 width=11) (actual time=13796.839..13803.559 rows=10 loops=1) + InitPlan 1 (returns $0) + -> Limit (cost=0.00..100.89 rows=1 width=8) (actual time=1.945..1.946 rows=1 loops=1) + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=31 width=8) (actual time=1.941..1.941 rows=1 loops=1) + Filter: ((d_year = 2001) AND (d_moy = 1)) + Rows Removed by Filter: 36889 + -> Sort (cost=878145.60..878145.65 rows=17 width=11) (actual time=13593.302..13600.020 rows=10 loops=1) + Sort Key: (count(*)), a.ca_state + Sort Method: top-N heapsort Memory: 25kB + -> Finalize GroupAggregate (cost=878120.69..878145.26 rows=17 width=11) (actual time=13592.621..13600.002 rows=51 loops=1) + Group Key: a.ca_state + Filter: (count(*) >= 10) + Rows Removed by Filter: 1 + -> Gather Merge (cost=878120.69..878144.11 rows=102 width=11) (actual time=13592.578..13599.963 rows=154 loops=1) + Workers Planned: 2 + Params Evaluated: $0 + Workers Launched: 2 + -> Partial GroupAggregate (cost=877120.66..877132.31 rows=51 width=11) (actual time=13575.680..13576.272 rows=51 loops=3) + Group Key: a.ca_state + -> Sort (cost=877120.66..877124.38 rows=1485 width=3) (actual time=13575.659..13575.913 rows=9110 loops=3) + Sort Key: a.ca_state + Sort Method: quicksort Memory: 510kB + Worker 0: Sort Method: quicksort Memory: 547kB + Worker 1: Sort Method: quicksort Memory: 511kB + -> Parallel Hash Join (cost=871115.95..877042.43 rows=1485 width=3) (actual time=13484.566..13573.921 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.201..82.985 rows=83333 loops=3) + -> Parallel Hash (cost=871097.39..871097.39 rows=1485 width=8) (actual time=13484.130..13484.138 rows=9110 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1632kB + -> Parallel Hash Join (cost=856354.61..871097.39 rows=1485 width=8) (actual time=13286.251..13472.082 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.177..173.987 rows=166667 loops=3) + -> Parallel Hash (cost=856335.13..856335.13 rows=1559 width=8) (actual time=13286.038..13286.045 rows=9322 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1600kB + -> Hash Join (cost=851212.38..856335.13 rows=1559 width=8) (actual time=13184.630..13280.778 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=845178.13..850286.05 rows=4690 width=20) (actual time=12989.745..13067.062 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.103..60.432 rows=34000 loops=3) + -> Parallel Hash (cost=845119.51..845119.51 rows=4690 width=16) (actual time=12989.583..12989.588 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 21632kB + -> Parallel Hash Join (cost=2569.35..845119.51 rows=4690 width=16) (actual time=2.976..12935.956 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..797525.83 rows=11998983 width=24) (actual time=1.069..12543.453 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=18 width=8) (actual time=1.103..1.103 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=1.663..3.299 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=194.838..194.838 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> HashAggregate (cost=6034.00..6034.12 rows=10 width=38) (actual time=194.829..194.832 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.019..9.678 rows=102000 loops=3) +Planning Time: 0.401 ms +JIT: + Functions: 182 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.383 ms, Inlining 94.056 ms, Optimization 375.123 ms, Emission 244.721 ms, Total 719.283 ms +Execution Time: 13805.637 ms","Limit (cost=883430.32..883430.34 rows=10 width=11) (actual time=13764.286..13773.103 rows=10 loops=1) + -> Sort (cost=883430.32..883430.36 rows=17 width=11) (actual time=13528.289..13537.105 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=883405.03..883429.97 rows=17 width=11) (actual time=13527.525..13537.081 rows=51 loops=1) + Group Key: customer_address.ca_state + Filter: (count(*) >= 10) + Rows Removed by Filter: 1 + -> Gather Merge (cost=883405.03..883428.82 rows=102 width=11) (actual time=13527.493..13537.049 rows=156 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=882405.00..882417.03 rows=51 width=11) (actual time=13512.201..13512.810 rows=52 loops=3) + Group Key: customer_address.ca_state + -> Sort (cost=882405.00..882408.84 rows=1535 width=3) (actual time=13512.182..13512.447 rows=9110 loops=3) + Sort Key: customer_address.ca_state + Sort Method: quicksort Memory: 516kB + Worker 0: Sort Method: quicksort Memory: 509kB + Worker 1: Sort Method: quicksort Memory: 542kB + -> Parallel Hash Right Join (cost=876397.08..882323.77 rows=1535 width=3) (actual time=13436.690..13510.526 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.218..67.168 rows=83333 loops=3) + -> Parallel Hash (cost=876377.89..876377.89 rows=1535 width=8) (actual time=13436.308..13436.317 rows=9110 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1600kB + -> Parallel Hash Join (cost=861634.92..876377.89 rows=1535 width=8) (actual time=13265.487..13423.459 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.207..146.135 rows=166667 loops=3) + -> Parallel Hash (cost=861614.78..861614.78 rows=1611 width=8) (actual time=13265.068..13265.076 rows=9322 loops=3) + Buckets: 32768 (originally 4096) Batches: 1 (originally 1) Memory Usage: 1568kB + -> Hash Join (cost=856490.90..861614.78 rows=1611 width=8) (actual time=13227.223..13260.914 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=850456.65..855565.21 rows=4846 width=20) (actual time=13019.916..13034.181 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.006..3.560 rows=34000 loops=3) + -> Parallel Hash (cost=850396.07..850396.07 rows=4846 width=30) (actual time=13019.854..13019.859 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 26592kB + -> Parallel Hash Join (cost=845287.51..850396.07 rows=4846 width=30) (actual time=12972.533..12998.557 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.008..3.772 rows=34000 loops=3) + -> Parallel Hash (cost=845226.93..845226.93 rows=4846 width=16) (actual time=12972.463..12972.467 rows=96339 loops=3) + Buckets: 524288 (originally 16384) Batches: 1 (originally 1) Memory Usage: 21632kB + -> Parallel Hash Join (cost=2676.78..845226.93 rows=4846 width=16) (actual time=3.560..12889.846 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..797525.83 rows=11998983 width=24) (actual time=1.586..12499.087 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=1.191..1.192 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=1.784..3.565 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=207.265..207.265 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> HashAggregate (cost=6034.00..6034.12 rows=10 width=38) (actual time=207.256..207.259 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.018..9.434 rows=102000 loops=3) +Planning Time: 0.666 ms +JIT: + Functions: 194 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.480 ms, Inlining 120.364 ms, Optimization 397.126 ms, Emission 262.181 ms, Total 784.150 ms +Execution Time: 14034.812 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",13.945264122000026,14.18717597099976,"Limit (cost=50011.86..70204.30 rows=10 width=145) (actual time=13847.852..14002.052 rows=10 loops=1) + -> GroupAggregate (cost=50011.86..3579650.06 rows=1748 width=145) (actual time=13847.851..14002.049 rows=10 loops=1) + Group Key: i.i_item_id + -> Nested Loop (cost=50011.86..3579593.25 rows=1748 width=40) (actual time=13844.826..14002.015 rows=19 loops=1) + Join Filter: (ss.ss_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 2340723 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=98.861..102.545 rows=32 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=61.824..61.854 rows=785 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 1936kB + Worker 1: Sort Method: quicksort Memory: 2312kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=0.007..5.954 rows=34000 loops=3) + -> Materialize (cost=40815.61..884081.80 rows=1748 width=31) (actual time=11.003..431.884 rows=73148 loops=32) + -> Gather (cost=40815.61..884073.06 rows=1748 width=31) (actual time=352.069..13722.013 rows=75483 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=39815.61..882898.26 rows=728 width=31) (actual time=342.213..13718.969 rows=25161 loops=3) + Hash Cond: (ss.ss_promo_sk = p.p_promo_sk) + -> Parallel Hash Join (cost=39790.86..882863.35 rows=764 width=39) (actual time=341.997..13715.331 rows=25586 loops=3) + Hash Cond: (ss.ss_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..845428.33 rows=56742 width=47) (actual time=3.501..13287.065 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..797525.83 rows=11998983 width=55) (actual time=0.171..12681.300 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=3.292..3.293 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=214 width=8) (actual time=1.625..3.254 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=335.687..335.688 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1344kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11298 width=8) (actual time=0.235..334.280 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.111..0.112 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.010..0.074 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.268 ms +Execution Time: 14002.784 ms","Limit (cost=890054.97..890054.99 rows=10 width=145) (actual time=13895.904..13896.442 rows=10 loops=1) + -> Sort (cost=890054.97..890059.23 rows=1703 width=145) (actual time=13725.898..13726.434 rows=10 loops=1) + Sort Key: item.i_item_id NULLS FIRST + Sort Method: top-N heapsort Memory: 26kB + -> Hash Join (cost=884226.41..890018.17 rows=1703 width=145) (actual time=13697.434..13719.436 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.011..8.711 rows=102000 loops=1) + -> Hash (cost=884205.12..884205.12 rows=1703 width=136) (actual time=13697.397..13697.933 rows=39288 loops=1) + Buckets: 65536 (originally 2048) Batches: 1 (originally 1) Memory Usage: 3153kB + -> Subquery Scan on _s7 (cost=883931.55..884205.12 rows=1703 width=136) (actual time=13611.640..13693.409 rows=39288 loops=1) + -> Finalize GroupAggregate (cost=883931.55..884188.09 rows=1703 width=136) (actual time=13611.637..13691.268 rows=39288 loops=1) + Group Key: store_sales.ss_item_sk + -> Gather Merge (cost=883931.55..884122.08 rows=1420 width=136) (actual time=13611.616..13637.022 rows=58941 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=882931.53..882958.15 rows=710 width=136) (actual time=13600.512..13618.577 rows=19647 loops=3) + Group Key: store_sales.ss_item_sk + -> Sort (cost=882931.53..882933.30 rows=710 width=31) (actual time=13600.468..13602.806 rows=24717 loops=3) + Sort Key: store_sales.ss_item_sk + Sort Method: quicksort Memory: 2310kB + Worker 0: Sort Method: quicksort Memory: 2270kB + Worker 1: Sort Method: quicksort Memory: 2341kB + -> Hash Join (cost=39815.45..882897.90 rows=710 width=31) (actual time=325.860..13595.817 rows=24717 loops=3) + Hash Cond: (store_sales.ss_promo_sk = promotion.p_promo_sk) + -> Parallel Hash Join (cost=39790.86..882863.35 rows=764 width=39) (actual time=211.297..13478.022 rows=25586 loops=3) + Hash Cond: (store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..845428.33 rows=56742 width=47) (actual time=2.258..13177.006 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..797525.83 rows=11998983 width=55) (actual time=0.160..12614.731 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.060..2.061 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=1.030..2.007 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=206.485..206.486 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11298 width=8) (actual time=0.222..204.831 rows=9147 loops=3) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 631120 + -> Hash (cost=18.50..18.50 rows=487 width=8) (actual time=114.542..114.543 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=114.410..114.495 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.251 ms +JIT: + Functions: 119 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.479 ms, Inlining 77.755 ms, Optimization 260.898 ms, Emission 174.728 ms, Total 516.860 ms +Execution Time: 13897.868 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",13.822256133999872,14.082679052000003,"Limit (cost=892706.34..892947.77 rows=10 width=36) (actual time=13789.643..13809.354 rows=8 loops=1) + -> GroupAggregate (cost=892706.34..892947.77 rows=10 width=36) (actual time=13528.067..13547.778 rows=8 loops=1) + Group Key: s.s_store_name + -> Sort (cost=892706.34..892786.77 rows=32174 width=10) (actual time=13523.260..13536.169 rows=192619 loops=1) + Sort Key: s.s_store_name + Sort Method: external merge Disk: 4112kB + -> Hash Join (cost=41473.23..890297.53 rows=32174 width=10) (actual time=408.273..13503.911 rows=192619 loops=1) + Hash Cond: (substr((s.s_zip)::text, 1, 2) = substr(a2.ca_zip, 1, 2)) + -> Gather (cost=3684.51..849693.58 rows=32174 width=16) (actual time=6.220..13029.218 rows=754280 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=2684.51..845476.18 rows=13406 width=16) (actual time=147.665..13229.684 rows=251427 loops=3) + Hash Cond: (ss.ss_store_sk = s.s_store_sk) + -> Parallel Hash Join (cost=2677.21..845282.08 rows=14068 width=14) (actual time=3.219..13060.525 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..797525.83 rows=11998983 width=22) (actual time=0.220..12666.845 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=53 width=8) (actual time=1.763..1.764 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=53 width=8) (actual time=2.535..5.230 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=144.361..144.361 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=144.307..144.342 rows=102 loops=3) + -> Hash (cost=37786.22..37786.22 rows=200 width=32) (actual time=402.037..404.095 rows=9 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Subquery Scan on a2 (cost=24521.26..37786.22 rows=200 width=32) (actual time=402.009..404.089 rows=9 loops=1) + -> HashSetOp Intersect (cost=24521.26..37786.22 rows=200 width=36) (actual time=402.004..404.083 rows=9 loops=1) + -> Append (cost=24521.26..37242.64 rows=217435 width=36) (actual time=373.624..403.705 rows=3229 loops=1) + -> Subquery Scan on ""*SELECT* 2"" (cost=24521.26..24587.27 rows=1100 width=36) (actual time=373.622..376.245 rows=2268 loops=1) + -> Subquery Scan on a1 (cost=24521.26..24576.27 rows=1100 width=32) (actual time=373.619..376.122 rows=2268 loops=1) + -> Finalize HashAggregate (cost=24521.26..24565.27 rows=1100 width=40) (actual time=373.615..375.995 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=23786.79..24488.25 rows=6602 width=40) (actual time=370.857..374.067 rows=11172 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=22786.79..22828.05 rows=3301 width=40) (actual time=357.984..358.270 rows=3724 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.54..22292.24 rows=98910 width=32) (actual time=237.455..349.903 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.297..91.358 rows=83333 loops=3) + -> Parallel Hash (cost=14476.17..14476.17 rows=98910 width=8) (actual time=236.589..236.589 rows=78942 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 11360kB + -> Parallel Seq Scan on customer c (cost=0.00..14476.17 rows=98910 width=8) (actual time=94.209..223.788 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.075..27.281 rows=961 loops=1) + -> Seq Scan on customer_address (cost=1.00..9404.84 rows=216335 width=32) (actual time=0.073..27.212 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.341 ms +JIT: + Functions: 135 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.786 ms, Inlining 210.782 ms, Optimization 488.262 ms, Emission 277.998 ms, Total 983.829 ms +Execution Time: 13811.603 ms","Limit (cost=877466.07..877466.27 rows=10 width=64) (actual time=13888.383..13896.751 rows=8 loops=1) + -> GroupAggregate (cost=877466.07..877467.09 rows=51 width=64) (actual time=13591.233..13599.599 rows=8 loops=1) + Group Key: _t1.anything_s_store_name + -> Sort (cost=877466.07..877466.20 rows=51 width=64) (actual time=13591.220..13599.584 rows=13 loops=1) + Sort Key: _t1.anything_s_store_name NULLS FIRST + Sort Method: quicksort Memory: 25kB + -> Subquery Scan on _t1 (cost=872911.93..877464.62 rows=51 width=64) (actual time=13487.879..13599.569 rows=13 loops=1) + -> GroupAggregate (cost=872911.93..877464.11 rows=51 width=72) (actual time=13487.876..13599.564 rows=13 loops=1) + Group Key: store_sales.ss_store_sk + -> Merge Join (cost=872911.93..877222.17 rows=32174 width=18) (actual time=13483.093..13587.934 rows=192619 loops=1) + Merge Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Gather Merge (cost=847251.40..851183.77 rows=33764 width=14) (actual time=13158.393..13225.137 rows=754281 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=846251.38..846286.55 rows=14068 width=14) (actual time=13148.556..13161.412 rows=252701 loops=3) + Sort Key: store_sales.ss_store_sk + Sort Method: external merge Disk: 6600kB + Worker 0: Sort Method: external merge Disk: 6392kB + Worker 1: Sort Method: external merge Disk: 6408kB + -> Parallel Hash Join (cost=2677.21..845282.08 rows=14068 width=14) (actual time=66.031..13119.949 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..797525.83 rows=11998983 width=22) (actual time=0.209..12673.632 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=53 width=8) (actual time=1.791..1.791 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=2.555..5.314 rows=91 loops=1) + Filter: ((d_qoy = 1) AND (d_year = 1998)) + Rows Removed by Filter: 72958 + -> Sort (cost=25660.53..25660.79 rows=102 width=12) (actual time=321.784..327.542 rows=192635 loops=1) + Sort Key: store.s_store_sk + Sort Method: quicksort Memory: 26kB + -> Hash Join (cost=25650.82..25657.13 rows=102 width=12) (actual time=321.716..322.273 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.007..0.021 rows=102 loops=1) + -> Hash (cost=25648.32..25648.32 rows=200 width=32) (actual time=321.689..322.189 rows=8 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 9kB + -> Group (cost=25642.32..25648.32 rows=200 width=32) (actual time=321.677..322.182 rows=8 loops=1) + Group Key: (SUBSTRING(_t3.zip FROM 1 FOR 2)) + -> Sort (cost=25642.32..25645.07 rows=1100 width=32) (actual time=321.672..322.172 rows=9 loops=1) + Sort Key: (SUBSTRING(_t3.zip FROM 1 FOR 2)) + Sort Method: quicksort Memory: 25kB + -> Subquery Scan on _t3 (cost=25528.99..25586.75 rows=1100 width=32) (actual time=321.649..322.157 rows=9 loops=1) + -> Finalize HashAggregate (cost=25528.99..25573.00 rows=1100 width=40) (actual time=321.645..322.151 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.51..25495.98 rows=6602 width=40) (actual time=321.387..322.120 rows=40 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial HashAggregate (cost=23794.51..23835.78 rows=3301 width=40) (actual time=311.088..311.097 rows=13 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.70 rows=85163 width=32) (actual time=149.440..311.003 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=98910 width=8) (actual time=0.221..157.349 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=148.134..148.135 rows=320 loops=3) + Buckets: 262144 Batches: 1 Memory Usage: 2144kB + -> Parallel Seq Scan on customer_address (cost=1.00..6832.75 rows=89689 width=14) (actual time=91.725..113.989 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.483 ms +JIT: + Functions: 122 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.322 ms, Inlining 146.055 ms, Optimization 377.639 ms, Emission 239.504 ms, Total 767.520 ms +Execution Time: 13899.460 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.20652225199956,66.90053598399982,"Seq Scan on reason (cost=12963547.46..12963560.73 rows=1 width=160) (actual time=134002.191..134008.598 rows=1 loops=1) + Filter: (r_reason_sk = 1) + Rows Removed by Filter: 44 + InitPlan 1 (returns $1) + -> Finalize Aggregate (cost=864297.47..864297.48 rows=1 width=8) (actual time=13125.421..13125.535 rows=1 loops=1) + -> Gather (cost=864297.26..864297.47 rows=2 width=8) (actual time=13125.275..13125.523 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863297.26..863297.27 rows=1 width=8) (actual time=13115.437..13115.438 rows=1 loops=3) + -> Parallel Seq Scan on store_sales (cost=0.00..857520.75 rows=2310604 width=0) (actual time=33.406..13065.020 rows=1832739 loops=3) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + Rows Removed by Filter: 7767592 + InitPlan 2 (returns $3) + -> Finalize Aggregate (cost=864297.48..864297.49 rows=1 width=32) (actual time=13415.141..13415.193 rows=1 loops=1) + -> Gather (cost=864297.26..864297.47 rows=2 width=32) (actual time=13414.984..13415.179 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863297.26..863297.27 rows=1 width=32) (actual time=13404.618..13404.619 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..857520.75 rows=2310604 width=3) (actual time=48.138..13294.370 rows=1832739 loops=3) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + Rows Removed by Filter: 7767592 + InitPlan 3 (returns $5) + -> Finalize Aggregate (cost=864297.48..864297.49 rows=1 width=32) (never executed) + -> Gather (cost=864297.26..864297.47 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863297.26..863297.27 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..857520.75 rows=2310604 width=6) (never executed) + Filter: ((ss_quantity >= 1) AND (ss_quantity <= 20)) + InitPlan 4 (returns $7) + -> Finalize Aggregate (cost=864127.49..864127.50 rows=1 width=8) (actual time=13368.011..13368.064 rows=1 loops=1) + -> Gather (cost=864127.28..864127.48 rows=2 width=8) (actual time=13367.858..13368.052 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863127.28..863127.29 rows=1 width=8) (actual time=13355.756..13355.757 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..857520.75 rows=2242610 width=0) (actual time=44.223..13305.228 rows=1832725 loops=3) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + Rows Removed by Filter: 7767605 + InitPlan 5 (returns $9) + -> Finalize Aggregate (cost=864127.50..864127.51 rows=1 width=32) (actual time=13361.544..13361.590 rows=1 loops=1) + -> Gather (cost=864127.28..864127.49 rows=2 width=32) (actual time=13361.382..13361.575 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863127.28..863127.29 rows=1 width=32) (actual time=13351.017..13351.018 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..857520.75 rows=2242610 width=3) (actual time=47.407..13240.516 rows=1832725 loops=3) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + Rows Removed by Filter: 7767605 + InitPlan 6 (returns $11) + -> Finalize Aggregate (cost=864127.50..864127.51 rows=1 width=32) (never executed) + -> Gather (cost=864127.28..864127.49 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863127.28..863127.29 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..857520.75 rows=2242610 width=6) (never executed) + Filter: ((ss_quantity >= 21) AND (ss_quantity <= 40)) + InitPlan 7 (returns $13) + -> Finalize Aggregate (cost=864247.48..864247.49 rows=1 width=8) (actual time=13386.764..13386.810 rows=1 loops=1) + -> Gather (cost=864247.27..864247.47 rows=2 width=8) (actual time=13386.604..13386.800 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863247.27..863247.28 rows=1 width=8) (actual time=13374.039..13374.040 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_6 (cost=0.00..857520.75 rows=2290606 width=0) (actual time=35.000..13323.481 rows=1834381 loops=3) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + Rows Removed by Filter: 7765949 + InitPlan 8 (returns $15) + -> Finalize Aggregate (cost=864247.49..864247.50 rows=1 width=32) (actual time=13375.731..13375.778 rows=1 loops=1) + -> Gather (cost=864247.27..864247.48 rows=2 width=32) (actual time=13375.560..13375.763 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863247.27..863247.28 rows=1 width=32) (actual time=13363.337..13363.338 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_7 (cost=0.00..857520.75 rows=2290606 width=3) (actual time=58.148..13254.185 rows=1834381 loops=3) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + Rows Removed by Filter: 7765949 + InitPlan 9 (returns $17) + -> Finalize Aggregate (cost=864247.49..864247.50 rows=1 width=32) (never executed) + -> Gather (cost=864247.27..864247.48 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863247.27..863247.28 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_8 (cost=0.00..857520.75 rows=2290606 width=6) (never executed) + Filter: ((ss_quantity >= 41) AND (ss_quantity <= 60)) + InitPlan 10 (returns $19) + -> Finalize Aggregate (cost=864217.48..864217.49 rows=1 width=8) (actual time=13369.077..13369.123 rows=1 loops=1) + -> Gather (cost=864217.27..864217.48 rows=2 width=8) (actual time=13368.915..13369.106 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863217.27..863217.28 rows=1 width=8) (actual time=13356.076..13356.076 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_9 (cost=0.00..857520.75 rows=2278607 width=0) (actual time=33.452..13306.887 rows=1835252 loops=3) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + Rows Removed by Filter: 7765079 + InitPlan 11 (returns $21) + -> Finalize Aggregate (cost=864217.49..864217.50 rows=1 width=32) (actual time=13365.344..13365.394 rows=1 loops=1) + -> Gather (cost=864217.27..864217.48 rows=2 width=32) (actual time=13365.177..13365.379 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863217.27..863217.28 rows=1 width=32) (actual time=13354.067..13354.068 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_10 (cost=0.00..857520.75 rows=2278607 width=3) (actual time=47.227..13242.143 rows=1835252 loops=3) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + Rows Removed by Filter: 7765079 + InitPlan 12 (returns $23) + -> Finalize Aggregate (cost=864217.49..864217.50 rows=1 width=32) (never executed) + -> Gather (cost=864217.27..864217.48 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863217.27..863217.28 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_11 (cost=0.00..857520.75 rows=2278607 width=6) (never executed) + Filter: ((ss_quantity >= 61) AND (ss_quantity <= 80)) + InitPlan 13 (returns $25) + -> Finalize Aggregate (cost=864292.48..864292.49 rows=1 width=8) (actual time=13378.667..13378.730 rows=1 loops=1) + -> Gather (cost=864292.26..864292.47 rows=2 width=8) (actual time=13378.506..13378.718 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863292.26..863292.27 rows=1 width=8) (actual time=13366.570..13366.571 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_12 (cost=0.00..857520.75 rows=2308605 width=0) (actual time=33.785..13315.419 rows=1833173 loops=3) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) + Rows Removed by Filter: 7767157 + InitPlan 14 (returns $27) + -> Finalize Aggregate (cost=864292.49..864292.50 rows=1 width=32) (actual time=13367.106..13372.978 rows=1 loops=1) + -> Gather (cost=864292.26..864292.47 rows=2 width=32) (actual time=13366.948..13372.961 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=863292.26..863292.27 rows=1 width=32) (actual time=13356.588..13356.589 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_13 (cost=0.00..857520.75 rows=2308605 width=3) (actual time=47.380..13245.142 rows=1833173 loops=3) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) + Rows Removed by Filter: 7767157 + InitPlan 15 (returns $29) + -> Finalize Aggregate (cost=864292.49..864292.50 rows=1 width=32) (never executed) + -> Gather (cost=864292.26..864292.47 rows=2 width=32) (never executed) + Workers Planned: 2 + Workers Launched: 0 + -> Partial Aggregate (cost=863292.26..863292.27 rows=1 width=32) (never executed) + -> Parallel Seq Scan on store_sales store_sales_14 (cost=0.00..857520.75 rows=2308605 width=6) (never executed) + Filter: ((ss_quantity >= 81) AND (ss_quantity <= 100)) +Planning Time: 0.217 ms +JIT: + Functions: 193 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 9.673 ms, Inlining 662.063 ms, Optimization 639.937 ms, Emission 444.636 ms, Total 1756.310 ms +Execution Time: 134011.881 ms","Nested Loop (cost=4378337.71..4378337.87 rows=1 width=160) (actual time=66673.953..66680.410 rows=1 loops=1) + -> Nested Loop (cost=3502502.18..3502502.29 rows=1 width=288) (actual time=53326.802..53327.055 rows=1 loops=1) + -> Nested Loop (cost=2626891.63..2626891.71 rows=1 width=216) (actual time=39982.926..39983.133 rows=1 loops=1) + -> Nested Loop (cost=1751191.09..1751191.15 rows=1 width=144) (actual time=26619.550..26619.708 rows=1 loops=1) + -> Finalize Aggregate (cost=875850.53..875850.54 rows=1 width=72) (actual time=13284.363..13284.467 rows=1 loops=1) + -> Gather (cost=875850.29..875850.49 rows=2 width=72) (actual time=13284.210..13284.449 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874850.29..874850.30 rows=1 width=72) (actual time=13271.312..13271.313 rows=1 loops=3) + -> Parallel Seq Scan on store_sales (cost=0.00..857520.75 rows=2310604 width=9) (actual time=158.102..13118.647 rows=1832739 loops=3) + Filter: ((ss_quantity <= 20) AND (ss_quantity >= 1)) + Rows Removed by Filter: 7767592 + -> Finalize Aggregate (cost=875340.57..875340.58 rows=1 width=72) (actual time=13335.179..13335.233 rows=1 loops=1) + -> Gather (cost=875340.33..875340.54 rows=2 width=72) (actual time=13335.026..13335.214 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874340.33..874340.34 rows=1 width=72) (actual time=13324.699..13324.700 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..857520.75 rows=2242610 width=9) (actual time=56.123..13162.653 rows=1832725 loops=3) + Filter: ((ss_quantity <= 40) AND (ss_quantity >= 21)) + Rows Removed by Filter: 7767605 + -> Finalize Aggregate (cost=875700.54..875700.55 rows=1 width=72) (actual time=13363.370..13363.418 rows=1 loops=1) + -> Gather (cost=875700.30..875700.51 rows=2 width=72) (actual time=13363.218..13363.399 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874700.30..874700.31 rows=1 width=72) (actual time=13352.093..13352.094 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..857520.75 rows=2290606 width=9) (actual time=55.355..13186.285 rows=1834381 loops=3) + Filter: ((ss_quantity <= 60) AND (ss_quantity >= 41)) + Rows Removed by Filter: 7765949 + -> Finalize Aggregate (cost=875610.55..875610.56 rows=1 width=72) (actual time=13343.870..13343.915 rows=1 loops=1) + -> Gather (cost=875610.31..875610.52 rows=2 width=72) (actual time=13343.713..13343.897 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874610.31..874610.32 rows=1 width=72) (actual time=13330.233..13330.234 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..857520.75 rows=2278607 width=9) (actual time=59.863..13169.138 rows=1835252 loops=3) + Filter: ((ss_quantity <= 80) AND (ss_quantity >= 61)) + Rows Removed by Filter: 7765079 + -> Finalize Aggregate (cost=875835.53..875835.54 rows=1 width=72) (actual time=13347.144..13353.347 rows=1 loops=1) + -> Gather (cost=875835.29..875835.50 rows=2 width=72) (actual time=13346.984..13353.329 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=874835.29..874835.30 rows=1 width=72) (actual time=13333.788..13333.789 rows=1 loops=3) + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..857520.75 rows=2308605 width=9) (actual time=56.281..13176.237 rows=1833173 loops=3) + Filter: ((ss_quantity <= 100) AND (ss_quantity >= 81)) + Rows Removed by Filter: 7767157 +Planning Time: 0.221 ms +JIT: + Functions: 89 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.854 ms, Inlining 365.056 ms, Optimization 472.557 ms, Emission 316.995 ms, Total 1161.462 ms +Execution Time: 66682.632 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",44.39636163200021,29.618039413999668,"Limit (cost=174519.60..22834533508.30 rows=10 width=98) (actual time=65159.837..66218.800 rows=10 loops=1) + -> GroupAggregate (cost=174519.60..522906995360.82 rows=229 width=98) (actual time=64959.712..66018.674 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.60..522906995353.38 rows=229 width=50) (actual time=64885.607..66018.651 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=2056.064..2164.997 rows=373090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=169734.95..171735.78 rows=800333 width=58) (actual time=1901.426..1926.284 rows=124822 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: 58896kB + Worker 0: Sort Method: external merge Disk: 42888kB + Worker 1: Sort Method: external merge Disk: 47048kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..31075.33 rows=800333 width=58) (actual time=36.401..158.510 rows=640267 loops=3) + -> Materialize (cost=3784.62..522899772466.19 rows=237 width=8) (actual time=0.083..0.169 rows=72 loops=373090) + -> Nested Loop Semi Join (cost=3784.62..522899772465.00 rows=237 width=8) (actual time=30881.125..62497.954 rows=72 loops=1) + Join Filter: (c.c_customer_sk = ss.ss_customer_sk) + Rows Removed by Join Filter: 435657934 + -> Nested Loop (cost=0.00..522897058046.00 rows=3723 width=16) (actual time=14890.628..23275.920 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=2482 width=8) (actual time=0.290..28.704 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..522877635945.00 rows=375000 width=24) (actual time=6.317..8.608 rows=59019 loops=2319) + -> Seq Scan on customer c (cost=0.00..522877631872.00 rows=375000 width=24) (actual time=14646.969..14863.749 rows=59019 loops=1) + Filter: ((hashed SubPlan 2) OR (hashed SubPlan 4)) + Rows Removed by Filter: 440981 + SubPlan 2 + -> Gather (cost=3784.62..302948.21 rows=8768 width=8) (actual time=12.495..4661.356 rows=211863 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.62..301071.41 rows=3653 width=8) (actual time=55.755..4654.763 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..287019.96 rows=2998796 width=16) (actual time=0.335..4505.558 rows=2399189 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=52 width=8) (actual time=3.773..3.774 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=52 width=8) (actual time=9.261..11.234 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.62..599844.58 rows=17457 width=8) (actual time=7905.316..9931.199 rows=404796 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.62..597098.88 rows=7274 width=8) (actual time=7891.898..8749.825 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..571766.37 rows=6001437 width=16) (actual time=0.468..8516.404 rows=4800420 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=52 width=8) (actual time=4.093..4.094 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=52 width=8) (actual time=10.059..12.203 rows=90 loops=1) + Filter: ((d_moy >= 1) AND (d_moy <= 3) AND (d_year = 2002)) + Rows Removed by Filter: 72959 + -> Materialize (cost=3784.62..849893.77 rows=33389 width=8) (actual time=0.010..51.486 rows=775192 loops=562) + -> Gather (cost=3784.62..849726.82 rows=33389 width=8) (actual time=5.259..13231.987 rows=830670 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=2784.62..845387.92 rows=13912 width=8) (actual time=57.519..13263.195 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..797525.83 rows=11998983 width=16) (actual time=0.174..12825.829 rows=9600330 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=52 width=8) (actual time=1.313..1.313 rows=30 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2783.97 rows=52 width=8) (actual time=2.050..3.883 rows=90 loops=1) + Filter: ((d_moy >= 1) AND (d_moy <= 3) AND (d_year = 2002)) + Rows Removed by Filter: 72959 +Planning Time: 0.399 ms +JIT: + Functions: 153 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.538 ms, Inlining 304.465 ms, Optimization 314.804 ms, Emission 200.012 ms, Total 824.820 ms +Execution Time: 66229.131 ms","Limit (cost=2241958.75..2241959.10 rows=10 width=98) (actual time=29052.253..29052.556 rows=10 loops=1) + CTE _t5 + -> Seq Scan on date_dim (cost=0.00..3310.36 rows=89 width=24) (actual time=2.110..4.046 rows=90 loops=1) + Filter: ((d_moy <= 3) AND (d_moy >= 1) AND (d_year = 2002)) + Rows Removed by Filter: 72959 + -> GroupAggregate (cost=2238648.39..2238652.28 rows=111 width=98) (actual time=28783.603..28783.903 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=2238648.39..2238648.67 rows=111 width=50) (actual time=28783.588..28783.886 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=2189160.51..2238644.62 rows=111 width=50) (actual time=28326.819..28783.829 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.225..396.961 rows=1920800 loops=1) + -> Hash (cost=2189159.12..2189159.12 rows=111 width=8) (actual time=28325.897..28326.194 rows=71 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 11kB + -> Subquery Scan on _t1 (cost=2189038.20..2189159.12 rows=111 width=8) (actual time=28325.761..28326.178 rows=72 loops=1) + -> GroupAggregate (cost=2189038.20..2189158.01 rows=111 width=32) (actual time=28325.758..28326.171 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=2189038.20..2189057.50 rows=7721 width=32) (actual time=28325.736..28326.060 rows=1009 loops=1) + Sort Key: _s12.ws_bill_customer_sk + Sort Method: quicksort Memory: 75kB + -> Hash Right Join (cost=1469956.77..2188539.63 rows=7721 width=32) (actual time=28040.250..28325.932 rows=1009 loops=1) + Hash Cond: (catalog_sales.cs_ship_customer_sk = _s12.ws_bill_customer_sk) + -> Hash Join (cost=2.89..716759.42 rows=695712 width=8) (actual time=9692.933..9968.638 rows=404796 loops=1) + Hash Cond: (catalog_sales.cs_sold_date_sk = _t7.d_date_sk) + -> Seq Scan on catalog_sales (cost=0.00..655786.48 rows=14403448 width=16) (actual time=0.005..9477.720 rows=14401261 loops=1) + -> Hash (cost=1.78..1.78 rows=89 width=8) (actual time=0.015..0.015 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 _t7 (cost=0.00..1.78 rows=89 width=8) (actual time=0.004..0.009 rows=90 loops=1) + -> Hash (cost=1469941.54..1469941.54 rows=987 width=24) (actual time=18341.093..18341.386 rows=572 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Subquery Scan on _s12 (cost=1469911.93..1469941.54 rows=987 width=24) (actual time=18340.913..18341.340 rows=572 loops=1) + -> GroupAggregate (cost=1469911.93..1469931.67 rows=987 width=24) (actual time=18340.910..18341.308 rows=572 loops=1) + Group Key: customer.c_customer_sk + -> Sort (cost=1469911.93..1469914.40 rows=987 width=24) (actual time=18340.869..18341.187 rows=829 loops=1) + Sort Key: customer.c_customer_sk + Sort Method: quicksort Memory: 59kB + -> Hash Right Join (cost=1109027.52..1469862.84 rows=987 width=24) (actual time=13601.135..18341.061 rows=829 loops=1) + Hash Cond: (web_sales.ws_bill_customer_sk = customer.c_customer_sk) + -> Hash Join (cost=2.89..359512.34 rows=351718 width=8) (actual time=0.566..4881.141 rows=211863 loops=1) + Hash Cond: (web_sales.ws_sold_date_sk = _t6.d_date_sk) + -> Seq Scan on web_sales (cost=0.00..329003.10 rows=7197110 width=16) (actual time=0.260..4631.044 rows=7197566 loops=1) + -> Hash (cost=1.78..1.78 rows=89 width=8) (actual time=0.025..0.025 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 _t6 (cost=0.00..1.78 rows=89 width=8) (actual time=0.009..0.015 rows=90 loops=1) + -> Hash (cost=1109012.29..1109012.29 rows=987 width=16) (actual time=13450.345..13450.633 rows=572 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 35kB + -> Hash Join (cost=1093757.65..1109012.29 rows=987 width=16) (actual time=13413.301..13450.574 rows=572 loops=1) + Hash Cond: (customer.c_customer_sk = store_sales.ss_customer_sk) + -> Gather (cost=7193.63..22435.24 rows=4964 width=16) (actual time=130.429..167.346 rows=4651 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=6193.63..20938.84 rows=2068 width=16) (actual time=119.692..353.102 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.211..223.938 rows=166667 loops=3) + -> Parallel Hash (cost=6180.71..6180.71 rows=1034 width=8) (actual time=119.075..119.076 rows=773 loops=3) + Buckets: 4096 Batches: 1 Memory Usage: 128kB + -> Parallel Seq Scan on customer_address (cost=0.00..6180.71 rows=1034 width=8) (actual time=73.155..93.114 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=1085320.98..1085320.98 rows=99443 width=8) (actual time=13282.824..13282.827 rows=67514 loops=1) + Buckets: 131072 Batches: 1 Memory Usage: 3662kB + -> HashAggregate (cost=1084326.55..1085320.98 rows=99443 width=8) (actual time=13271.491..13278.106 rows=67514 loops=1) + Group Key: store_sales.ss_customer_sk + Batches: 1 Memory Usage: 5905kB + -> Hash Join (cost=2.89..1081138.56 rows=1275198 width=8) (actual time=4.863..13210.622 rows=811066 loops=1) + Hash Cond: (store_sales.ss_sold_date_sk = _t5.d_date_sk) + -> Seq Scan on store_sales (cost=0.00..965511.60 rows=27432556 width=16) (actual time=0.165..12260.928 rows=27504024 loops=1) + Filter: (ss_customer_sk IS NOT NULL) + Rows Removed by Filter: 1296967 + -> Hash (cost=1.78..1.78 rows=89 width=8) (actual time=4.070..4.071 rows=90 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t5 (cost=0.00..1.78 rows=89 width=8) (actual time=2.114..4.061 rows=90 loops=1) +Planning Time: 0.457 ms +JIT: + Functions: 127 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.610 ms, Inlining 67.355 ms, Optimization 248.851 ms, Emission 171.738 ms, Total 491.554 ms +Execution Time: 29055.158 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",516.3718385890002,35.01761257199996,"Limit (cost=11758388.60..11842980.98 rows=100 width=392) (actual time=233722.965..537231.671 rows=100 loops=1) + CTE year_total + -> Append (cost=4012590.20..10083627.52 rows=33300686 width=142) (actual time=57944.456..74998.505 rows=2079862 loops=1) + -> Finalize GroupAggregate (cost=4012590.20..7828918.39 rows=26105735 width=142) (actual time=57944.454..63459.214 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=4012590.20..6958727.20 rows=21754780 width=110) (actual time=57944.409..62755.416 rows=1627511 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=4011590.17..4446685.77 rows=10877390 width=110) (actual time=53884.415..58055.234 rows=542504 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=4011590.17..4038783.65 rows=10877390 width=88) (actual time=53884.352..55753.938 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: 821520kB + Worker 0: Sort Method: external merge Disk: 983192kB + Worker 1: Sort Method: external merge Disk: 903744kB + -> Parallel Hash Join (cost=22203.32..1178797.01 rows=10877390 width=88) (actual time=16735.147..22475.172 rows=8951983 loops=3) + Hash Cond: (ss.ss_customer_sk = c.c_customer_sk) + -> Parallel Hash Join (cost=2998.82..912689.26 rows=11418632 width=26) (actual time=6.829..15466.473 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..797525.83 rows=11998983 width=26) (actual time=0.212..14269.209 rows=9600330 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=16) (actual time=6.167..6.168 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4512kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2461.70 rows=42970 width=16) (actual time=0.023..2.797 rows=24350 loops=3) + -> Parallel Hash (cost=13955.33..13955.33 rows=208333 width=78) (actual time=240.349..240.350 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=155.556..186.901 rows=166667 loops=3) + -> Finalize GroupAggregate (cost=1036395.01..2088205.70 rows=7194951 width=142) (actual time=9408.874..11438.204 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=1036395.01..1848374.02 rows=5995792 width=110) (actual time=9408.856..11131.661 rows=538035 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1035394.98..1155310.82 rows=2997896 width=110) (actual time=9377.804..10904.593 rows=179345 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=1035394.98..1042889.72 rows=2997896 width=91) (actual time=9377.742..10279.437 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: 199992kB + Worker 0: Sort Method: external merge Disk: 201440kB + Worker 1: Sort Method: external merge Disk: 347920kB + -> Parallel Hash Join (cost=22203.32..405483.54 rows=2997896 width=91) (actual time=4936.761..5277.980 rows=2398314 loops=3) + Hash Cond: (ws.ws_bill_customer_sk = c_1.c_customer_sk) + -> Parallel Hash Join (cost=2998.82..318902.48 rows=2998496 width=29) (actual time=7.064..4421.654 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..287019.96 rows=2998796 width=29) (actual time=0.274..4120.036 rows=2399189 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=16) (actual time=6.296..6.297 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 4480kB + -> Parallel Seq Scan on date_dim d_1 (cost=0.00..2461.70 rows=42970 width=16) (actual time=0.017..2.809 rows=24350 loops=3) + -> Parallel Hash (cost=13955.33..13955.33 rows=208333 width=78) (actual time=258.066..258.067 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=165.902..211.255 rows=166667 loops=3) + -> Incremental Sort (cost=1674761.08..3565400.91 rows=2235 width=392) (actual time=233187.571..536602.927 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=1665115.12..3565329.87 rows=2235 width=392) (actual time=76610.265..536602.698 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=1665115.12..2602636.00 rows=4823 width=460) (actual time=76093.427..366831.038 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=1665115.12..1665171.32 rows=3469 width=378) (actual time=75893.031..75899.961 rows=1447 loops=1) + Merge Cond: ((t_s_secyear.customer_id)::text = (t_w_secyear.customer_id)::text) + -> Sort (cost=832557.56..832559.64 rows=833 width=296) (actual time=75719.720..75721.670 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..832517.15 rows=833 width=296) (actual time=57944.480..75642.799 rows=307975 loops=1) + Filter: ((sale_type = 's'::text) AND (dyear = 2001)) + Rows Removed by Filter: 1771887 + -> Sort (cost=832557.56..832559.64 rows=833 width=82) (actual time=173.254..174.131 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..832517.15 rows=833 width=82) (actual time=101.481..136.782 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..915768.87 rows=278 width=82) (actual time=0.001..191.543 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..915768.87 rows=278 width=82) (actual time=132.673..181.410 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.409 ms +JIT: + Functions: 178 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.349 ms, Inlining 221.353 ms, Optimization 801.190 ms, Emission 476.822 ms, Total 1507.714 ms +Execution Time: 537304.566 ms","Limit (cost=10847882.37..10847882.54 rows=67 width=256) (actual time=39517.057..39517.083 rows=100 loops=1) + CTE _s0 + -> Seq Scan on store_sales (cost=0.00..965511.60 rows=28797560 width=26) (actual time=0.278..9840.295 rows=28800991 loops=1) + CTE _t4 + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=363 width=16) (actual time=1.644..3.259 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=363 width=16) (actual time=1.691..3.317 rows=365 loops=1) + Filter: (d_year = 2001) + Rows Removed by Filter: 72684 + CTE _s8 + -> Seq Scan on web_sales (cost=0.00..329003.10 rows=7197110 width=29) (actual time=0.338..3014.638 rows=7197566 loops=1) + -> Sort (cost=9547477.45..9547477.62 rows=67 width=256) (actual time=39098.370..39098.388 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=9547470.39..9547475.42 rows=67 width=256) (actual time=38917.665..39097.007 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=8833048.46..8833050.96 rows=200 width=232) (actual time=34076.979..34244.864 rows=40913 loops=1) + Group Key: _s8.ws_bill_customer_sk + Batches: 5 Memory Usage: 7617kB Disk Usage: 36184kB + -> Hash Join (cost=7903411.24..8539136.47 rows=13062755 width=228) (actual time=32576.259..33895.943 rows=550891 loops=1) + Hash Cond: (_s8.ws_sold_date_sk = _t6.d_date_sk) + -> Hash Join (cost=7903399.44..8066634.40 rows=7197110 width=236) (actual time=32572.466..33759.210 rows=2745884 loops=1) + Hash Cond: (_s8.ws_bill_customer_sk = _s10.c_customer_sk) + -> CTE Scan on _s8 (cost=0.00..143942.20 rows=7197110 width=44) (actual time=0.023..345.513 rows=7197566 loops=1) + -> Hash (cost=7903396.94..7903396.94 rows=200 width=200) (actual time=32572.358..32572.367 rows=190292 loops=1) + Buckets: 131072 (originally 1024) Batches: 4 (originally 1) Memory Usage: 7169kB + -> Subquery Scan on _s10 (cost=7903392.44..7903396.94 rows=200 width=200) (actual time=31634.630..32545.825 rows=190292 loops=1) + -> HashAggregate (cost=7903392.44..7903394.94 rows=200 width=200) (actual time=31634.627..32536.296 rows=190292 loops=1) + Group Key: _s4.ss_customer_sk + Batches: 37 Memory Usage: 8385kB Disk Usage: 236432kB + -> Hash Join (cost=4314334.55..6858041.02 rows=52267571 width=196) (actual time=25172.140..30833.010 rows=3301970 loops=1) + Hash Cond: (_s4.ss_sold_date_sk = _t5.d_date_sk) + -> Hash Join (cost=4314322.75..4967469.41 rows=28797560 width=204) (actual time=25172.068..29965.534 rows=19103439 loops=1) + Hash Cond: (_s4.ss_customer_sk = _s6.c_customer_sk) + -> CTE Scan on _s0 _s4 (cost=0.00..575951.20 rows=28797560 width=44) (actual time=0.279..1314.909 rows=28800991 loops=1) + -> Hash (cost=4314320.25..4314320.25 rows=200 width=168) (actual time=25171.365..25171.371 rows=309098 loops=1) + Buckets: 131072 (originally 1024) Batches: 4 (originally 1) Memory Usage: 7393kB + -> Subquery Scan on _s6 (cost=4314315.75..4314320.25 rows=200 width=168) (actual time=23768.469..25131.855 rows=309098 loops=1) + -> HashAggregate (cost=4314315.75..4314318.25 rows=200 width=168) (actual time=23768.466..25116.413 rows=309098 loops=1) + Group Key: _s0.ss_customer_sk + Batches: 53 Memory Usage: 8361kB Disk Usage: 352016kB + -> Hash Join (cost=27040.80..3399633.26 rows=52267571 width=67) (actual time=165.284..22605.639 rows=5389360 loops=1) + Hash Cond: (_s0.ss_sold_date_sk = _t4.d_date_sk) + -> Hash Join (cost=27029.00..1509061.65 rows=28797560 width=75) (actual time=164.959..21321.582 rows=27504024 loops=1) + Hash Cond: (_s0.ss_customer_sk = customer.c_customer_sk) + -> CTE Scan on _s0 (cost=0.00..575951.20 rows=28797560 width=44) (actual time=0.002..14075.310 rows=28800991 loops=1) + -> Hash (cost=16872.00..16872.00 rows=500000 width=39) (actual time=164.858..164.859 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.163..104.612 rows=500000 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=0.035..0.036 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 (cost=0.00..7.26 rows=363 width=8) (actual time=0.002..0.016 rows=366 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=0.037..0.038 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 (cost=0.00..7.26 rows=363 width=8) (actual time=0.003..0.017 rows=365 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=3.317..3.318 rows=366 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t4 _t6 (cost=0.00..7.26 rows=363 width=8) (actual time=1.648..3.296 rows=366 loops=1) + -> Hash (cost=714419.44..714419.44 rows=200 width=40) (actual time=4840.641..4840.644 rows=106184 loops=1) + Buckets: 131072 (originally 1024) Batches: 1 (originally 1) Memory Usage: 6805kB + -> Subquery Scan on _s15 (cost=714414.94..714419.44 rows=200 width=40) (actual time=4649.016..4834.686 rows=106185 loops=1) + -> HashAggregate (cost=714414.94..714417.44 rows=200 width=40) (actual time=4649.011..4829.472 rows=106185 loops=1) + Group Key: _s12.ws_bill_customer_sk + Batches: 21 Memory Usage: 8265kB Disk Usage: 48368kB + -> Hash Join (cost=11.80..616444.27 rows=13062755 width=36) (actual time=3.767..4399.621 rows=1432881 loops=1) + Hash Cond: (_s12.ws_sold_date_sk = _t8.d_date_sk) + -> CTE Scan on _s8 _s12 (cost=0.00..143942.20 rows=7197110 width=44) (actual time=0.341..3989.033 rows=7197566 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=3.377..3.377 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 _t8 (cost=0.00..7.26 rows=363 width=8) (actual time=1.694..3.354 rows=365 loops=1) +Planning Time: 0.367 ms +JIT: + Functions: 111 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 5.603 ms, Inlining 64.998 ms, Optimization 369.687 ms, Emission 280.551 ms, Total 720.838 ms +Execution Time: 39734.692 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.708110483000382,1.6675282300002436,"Limit (cost=307338.78..307339.03 rows=100 width=203) (actual time=414.797..415.670 rows=100 loops=1) + -> Sort (cost=307338.78..307341.02 rows=898 width=203) (actual time=405.799..406.667 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=307284.25..307304.46 rows=898 width=203) (actual time=399.318..404.417 rows=11201 loops=1) + -> Sort (cost=307284.25..307286.50 rows=898 width=171) (actual time=399.230..400.452 rows=11201 loops=1) + Sort Key: i.i_class + Sort Method: quicksort Memory: 2307kB + -> Finalize GroupAggregate (cost=307118.33..307240.20 rows=898 width=171) (actual time=383.739..396.599 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=307118.33..307215.89 rows=748 width=171) (actual time=383.728..391.700 rows=11201 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=306118.30..306129.52 rows=374 width=171) (actual time=373.634..375.928 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=306118.30..306119.24 rows=374 width=145) (actual time=373.616..373.845 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: 1944kB + Worker 0: Sort Method: quicksort Memory: 1133kB + Worker 1: Sort Method: quicksort Memory: 1193kB + -> Parallel Hash Join (cost=300965.51..306102.32 rows=374 width=145) (actual time=351.962..362.474 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=12501 width=147) (actual time=0.055..9.146 rows=10145 loops=3) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 23855 + -> Parallel Hash (cost=300949.61..300949.61 rows=1272 width=14) (actual time=351.649..351.651 rows=22946 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 5280kB + -> Parallel Hash Join (cost=2676.78..300949.61 rows=1272 width=14) (actual time=8.257..333.088 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..287019.96 rows=2998796 width=22) (actual time=0.015..209.452 rows=2399189 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=1.721..1.722 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.477..5.151 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.212 ms +JIT: + Functions: 93 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.719 ms, Inlining 0.000 ms, Optimization 1.662 ms, Emission 25.970 ms, Total 31.351 ms +Execution Time: 417.388 ms","Limit (cost=678758.40..678758.65 rows=100 width=200) (actual time=1937.876..1939.276 rows=100 loops=1) + CTE _t3 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=31 width=12) (actual time=1.730..3.396 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=675630.67..675635.24 rows=1828 width=200) (actual time=1666.755..1668.149 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=675510.53..675560.80 rows=1828 width=200) (actual time=1660.583..1666.309 rows=11177 loops=1) + -> Sort (cost=675510.53..675515.10 rows=1828 width=192) (actual time=1660.517..1662.244 rows=11177 loops=1) + Sort Key: _t0.anything_i_class + Sort Method: quicksort Memory: 2298kB + -> Subquery Scan on _t0 (cost=675333.80..675411.49 rows=1828 width=192) (actual time=1648.215..1659.141 rows=11177 loops=1) + -> GroupAggregate (cost=675333.80..675393.21 rows=1828 width=200) (actual time=1648.212..1658.546 rows=11177 loops=1) + Group Key: web_sales.ws_item_sk + -> Sort (cost=675333.80..675338.37 rows=1828 width=153) (actual time=1648.175..1650.884 rows=20442 loops=1) + Sort Key: web_sales.ws_item_sk + Sort Method: external merge Disk: 3312kB + -> Hash Join (cost=365617.92..675234.76 rows=1828 width=153) (actual time=992.900..1642.065 rows=20442 loops=1) + Hash Cond: (item.i_item_sk = web_sales_1.ws_item_sk) + -> Hash Join (cost=6203.56..315815.60 rows=1828 width=161) (actual time=186.544..832.690 rows=20442 loops=1) + Hash Cond: (web_sales.ws_sold_date_sk = _t4.d_date_sk) + -> Gather (cost=6202.55..315393.59 rows=107392 width=169) (actual time=182.780..672.825 rows=2141448 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5202.55..303654.39 rows=44747 width=169) (actual time=173.167..657.494 rows=713816 loops=3) + Hash Cond: (web_sales.ws_item_sk = item.i_item_sk) + -> Parallel Seq Scan on web_sales (cost=0.00..287019.96 rows=2998796 width=22) (actual time=0.009..217.287 rows=2399189 loops=3) + -> Parallel Hash (cost=5194.62..5194.62 rows=634 width=147) (actual time=172.964..172.965 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=634 width=147) (actual time=105.498..118.670 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.62..0.62 rows=31 width=8) (actual time=3.409..3.410 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 _t4 (cost=0.00..0.62 rows=31 width=8) (actual time=1.735..3.403 rows=31 loops=1) + -> Hash (cost=358364.51..358364.51 rows=83988 width=8) (actual time=806.310..806.313 rows=37612 loops=1) + Buckets: 131072 Batches: 1 Memory Usage: 2494kB + -> HashAggregate (cost=357524.63..358364.51 rows=83988 width=8) (actual time=801.519..803.616 rows=37612 loops=1) + Group Key: web_sales_1.ws_item_sk + Batches: 1 Memory Usage: 4625kB + -> Hash Join (cost=1.01..357218.36 rows=122509 width=8) (actual time=0.056..793.346 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..329003.10 rows=7197110 width=16) (actual time=0.006..554.950 rows=7197566 loops=1) + Filter: (ws_item_sk IS NOT NULL) + -> 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 (cost=0.00..0.62 rows=31 width=8) (actual time=0.003..0.006 rows=31 loops=1) +Planning Time: 0.306 ms +JIT: + Functions: 91 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.807 ms, Inlining 73.772 ms, Optimization 307.380 ms, Emission 206.375 ms, Total 591.334 ms +Execution Time: 1941.895 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",13.871725134000371,14.071125608999864,"Finalize Aggregate (cost=906845.03..906845.04 rows=1 width=128) (actual time=13837.874..13846.935 rows=1 loops=1) + -> Gather (cost=906844.78..906844.99 rows=2 width=128) (actual time=13836.756..13846.913 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=905844.78..905844.79 rows=1 width=128) (actual time=13826.938..13827.242 rows=1 loops=3) + -> Hash Join (cost=899530.71..905843.72 rows=140 width=20) (actual time=13760.864..13826.910 rows=3246 loops=3) + Hash Cond: (store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk) + -> Hash Join (cost=899304.71..905615.78 rows=146 width=28) (actual time=13494.818..13560.088 rows=3249 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=899297.42..905606.46 rows=153 width=36) (actual time=13494.758..13559.639 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=41264 width=8) (actual time=0.216..62.773 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=899292.31..899292.31 rows=407 width=44) (actual time=13494.408..13494.709 rows=13988 loops=3) + Buckets: 65536 (originally 1024) Batches: 1 (originally 1) Memory Usage: 4312kB + -> Parallel Hash Join (cost=861442.78..899292.31 rows=407 width=44) (actual time=13045.979..13476.541 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=205332 width=8) (actual time=0.239..409.817 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=861421.98..861421.98 rows=1664 width=52) (actual time=13045.639..13045.939 rows=55110 loops=3) + Buckets: 262144 (originally 4096) Batches: 1 (originally 1) Memory Usage: 18144kB + -> Parallel Hash Join (cost=2571.80..861421.98 rows=1664 width=52) (actual time=3.069..12955.653 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..857520.75 rows=351898 width=60) (actual time=0.432..12928.475 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=214 width=8) (actual time=1.722..1.723 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=2.727..5.135 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.046..0.046 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.026..0.038 rows=102 loops=3) + -> Hash (cost=136.00..136.00 rows=7200 width=8) (actual time=265.962..265.962 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=265.086..265.451 rows=7200 loops=3) +Planning Time: 0.317 ms +JIT: + Functions: 152 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.638 ms, Inlining 87.855 ms, Optimization 448.379 ms, Emission 259.197 ms, Total 800.070 ms +Execution Time: 13848.782 ms","Finalize Aggregate (cost=906845.74..906845.75 rows=1 width=128) (actual time=13879.103..13889.609 rows=1 loops=1) + -> Gather (cost=906845.48..906845.69 rows=2 width=128) (actual time=13877.953..13889.593 rows=3 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial Aggregate (cost=905845.48..905845.49 rows=1 width=128) (actual time=13868.055..13868.284 rows=1 loops=3) + -> Hash Join (cost=899530.71..905843.72 rows=140 width=20) (actual time=13784.664..13867.783 rows=3246 loops=3) + Hash Cond: (store_sales.ss_hdemo_sk = household_demographics.hd_demo_sk) + -> Hash Join (cost=899304.71..905615.78 rows=146 width=28) (actual time=13522.157..13604.508 rows=3249 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=899297.42..905606.46 rows=153 width=36) (actual time=13522.098..13604.085 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=41264 width=8) (actual time=0.305..80.076 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=899292.31..899292.31 rows=407 width=44) (actual time=13521.663..13521.889 rows=13988 loops=3) + Buckets: 65536 (originally 1024) Batches: 1 (originally 1) Memory Usage: 4344kB + -> Parallel Hash Join (cost=861442.78..899292.31 rows=407 width=44) (actual time=13041.739..13504.633 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=205332 width=8) (actual time=0.351..443.069 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=861421.98..861421.98 rows=1664 width=52) (actual time=13041.257..13041.483 rows=55110 loops=3) + Buckets: 262144 (originally 4096) Batches: 1 (originally 1) Memory Usage: 18112kB + -> Parallel Hash Join (cost=2571.80..861421.98 rows=1664 width=52) (actual time=3.245..12960.915 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..857520.75 rows=351898 width=60) (actual time=1.273..12934.346 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=214 width=8) (actual time=1.712..1.713 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=2.689..5.105 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.045..0.045 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.024..0.037 rows=102 loops=3) + -> Hash (cost=136.00..136.00 rows=7200 width=8) (actual time=262.424..262.424 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=261.527..261.894 rows=7200 loops=3) +Planning Time: 0.335 ms +JIT: + Functions: 152 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.796 ms, Inlining 87.426 ms, Optimization 441.096 ms, Emission 256.226 ms, Total 789.544 ms +Execution Time: 13891.609 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.219650623999769,10.415381953999713,"Limit (cost=619248.37..619260.70 rows=100 width=38) (actual time=10230.488..10241.916 rows=100 loops=1) + -> Finalize GroupAggregate (cost=619248.37..619520.25 rows=2205 width=38) (actual time=10071.142..10082.564 rows=100 loops=1) + Group Key: customer_address.ca_zip + -> Gather Merge (cost=619248.37..619478.90 rows=1838 width=38) (actual time=10071.123..10082.479 rows=176 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=618248.34..618266.72 rows=919 width=38) (actual time=10060.313..10061.237 rows=220 loops=3) + Group Key: customer_address.ca_zip + -> Sort (cost=618248.34..618250.64 rows=919 width=12) (actual time=10060.274..10060.677 rows=7474 loops=3) + Sort Key: customer_address.ca_zip + Sort Method: quicksort Memory: 802kB + Worker 0: Sort Method: quicksort Memory: 809kB + Worker 1: Sort Method: quicksort Memory: 817kB + -> Parallel Hash Join (cost=612208.79..618203.11 rows=919 width=12) (actual time=9978.872..10057.075 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.161..47.318 rows=83333 loops=3) + -> Parallel Hash (cost=612115.27..612115.27 rows=7480 width=14) (actual time=9978.090..9978.272 rows=137205 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=597087.10..612115.27 rows=7480 width=14) (actual time=9757.861..9953.633 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.245..170.162 rows=166667 loops=3) + -> Parallel Hash (cost=596993.11..596993.11 rows=7519 width=14) (actual time=9757.533..9757.714 rows=137555 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27328kB + -> Parallel Hash Join (cost=2677.23..596993.11 rows=7519 width=14) (actual time=7723.343..9734.883 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..571766.37 rows=6001437 width=22) (actual time=0.239..9414.579 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=54 width=8) (actual time=1.745..1.746 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=2.599..5.216 rows=91 loops=1) + Filter: ((d_qoy = 2) AND (d_year = 2001)) + Rows Removed by Filter: 72958 +Planning Time: 0.233 ms +JIT: + Functions: 118 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.729 ms, Inlining 79.348 ms, Optimization 298.347 ms, Emission 187.149 ms, Total 568.573 ms +Execution Time: 10243.546 ms","Limit (cost=619508.45..619521.13 rows=100 width=64) (actual time=10189.552..10200.355 rows=100 loops=1) + -> Finalize GroupAggregate (cost=619508.45..619786.63 rows=2194 width=64) (actual time=10006.624..10017.419 rows=100 loops=1) + Group Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) + -> Gather Merge (cost=619508.45..619740.01 rows=1828 width=64) (actual time=10006.607..10017.330 rows=177 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=618508.43..618528.99 rows=914 width=64) (actual time=9995.159..9995.917 rows=232 loops=3) + Group Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) + -> Sort (cost=618508.43..618510.71 rows=914 width=38) (actual time=9995.124..9995.350 rows=7742 loops=3) + Sort Key: (SUBSTRING(customer_address.ca_zip FROM 1 FOR 5)) NULLS FIRST + Sort Method: quicksort Memory: 756kB + Worker 0: Sort Method: quicksort Memory: 747kB + Worker 1: Sort Method: quicksort Memory: 906kB + -> Parallel Hash Join (cost=612208.79..618463.48 rows=914 width=38) (actual time=9902.317..9991.962 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.202..60.411 rows=80800 loops=3) + Filter: (SUBSTRING(ca_zip FROM 1 FOR 5) IS NOT NULL) + Rows Removed by Filter: 2533 + -> Parallel Hash (cost=612115.27..612115.27 rows=7480 width=14) (actual time=9901.506..9901.511 rows=137205 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=597087.10..612115.27 rows=7480 width=14) (actual time=9698.522..9877.238 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.178..153.429 rows=166667 loops=3) + -> Parallel Hash (cost=596993.11..596993.11 rows=7519 width=14) (actual time=9698.269..9698.272 rows=137555 loops=3) + Buckets: 524288 (originally 32768) Batches: 1 (originally 1) Memory Usage: 27296kB + -> Parallel Hash Join (cost=2677.23..596993.11 rows=7519 width=14) (actual time=7675.274..9675.931 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..571766.37 rows=6001437 width=22) (actual time=0.124..9341.469 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=54 width=8) (actual time=1.763..1.764 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=2.669..5.271 rows=91 loops=1) + Filter: ((d_qoy = 2) AND (d_year = 2001)) + Rows Removed by Filter: 72958 +Planning Time: 0.274 ms +JIT: + Functions: 124 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.080 ms, Inlining 77.250 ms, Optimization 338.604 ms, Emission 212.569 ms, Total 632.502 ms +Execution Time: 10202.111 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",12.280818022999483,11.323835354999574,"Limit (cost=695313.58..695313.83 rows=100 width=272) (actual time=12535.969..12584.567 rows=100 loops=1) + -> Sort (cost=695313.58..695317.00 rows=1365 width=272) (actual time=12157.229..12205.821 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=695169.67..695261.41 rows=1365 width=272) (actual time=12050.009..12192.692 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=695169.67..695209.38 rows=341 width=93) (actual time=12049.973..12106.819 rows=14238 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=694169.65..694170.00 rows=142 width=93) (actual time=12038.109..12038.370 rows=4746 loops=3) + Sort Key: i.i_item_id, ca.ca_country, ca.ca_state, ca.ca_county + Sort Method: quicksort Memory: 729kB + Worker 0: Sort Method: quicksort Memory: 875kB + Worker 1: Sort Method: quicksort Memory: 723kB + -> Parallel Hash Join (cost=689075.61..694164.57 rows=142 width=93) (actual time=12014.197..12029.282 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..10.248 rows=34000 loops=3) + -> Parallel Hash (cost=689073.83..689073.83 rows=142 width=84) (actual time=12014.044..12014.113 rows=4746 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2040kB + -> Parallel Hash Join (cost=654996.66..689073.83 rows=142 width=84) (actual time=11936.517..12006.264 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.006..35.062 rows=640267 loops=3) + -> Parallel Hash (cost=654994.81..654994.81 rows=148 width=92) (actual time=11936.176..11936.244 rows=4802 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2136kB + -> Parallel Hash Join (cost=648626.30..654994.81 rows=148 width=92) (actual time=11874.081..11931.381 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=15195 width=39) (actual time=0.236..55.606 rows=12282 loops=3) + Filter: ((ca_state)::text = ANY ('{MS,IN,ND,OK,NM,VA}'::text[])) + Rows Removed by Filter: 71052 + -> Parallel Hash (cost=648613.66..648613.66 rows=1011 width=69) (actual time=11873.807..11873.874 rows=32138 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 12032kB + -> Parallel Hash Join (cost=632717.19..648613.66 rows=1011 width=69) (actual time=11657.278..11867.549 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=99847 width=32) (actual time=0.207..199.518 rows=79880 loops=3) + Filter: (c_birth_month = ANY ('{1,2,6,8,9,12}'::bigint[])) + Rows Removed by Filter: 86787 + -> Parallel Hash (cost=632690.69..632690.69 rows=2120 width=53) (actual time=11657.028..11657.093 rows=67467 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 21792kB + -> Parallel Hash Join (cost=597389.31..632690.69 rows=2120 width=53) (actual time=11175.183..11633.035 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=57482 width=16) (actual time=0.212..424.308 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=597018.46..597018.46 rows=29668 width=53) (actual time=10719.070..10719.083 rows=950367 loops=3) + Buckets: 131072 (originally 131072) Batches: 32 (originally 1) Memory Usage: 9024kB + -> Parallel Hash Join (cost=2571.80..597018.46 rows=29668 width=53) (actual time=1491.596..10507.359 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..571766.37 rows=6001437 width=61) (actual time=0.140..9950.109 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=1.540..1.541 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=214 width=8) (actual time=2.241..4.576 rows=365 loops=1) + Filter: (d_year = 1998) + Rows Removed by Filter: 72684 +Planning Time: 0.785 ms +JIT: + Functions: 193 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.899 ms, Inlining 72.143 ms, Optimization 671.560 ms, Emission 435.375 ms, Total 1185.976 ms +Execution Time: 12587.447 ms","Limit (cost=666335.05..666349.55 rows=100 width=104) (actual time=12606.762..12681.805 rows=100 loops=1) + -> GroupAggregate (cost=666335.05..666386.38 rows=354 width=104) (actual time=12201.310..12276.349 rows=100 loops=1) + Group Key: _s8.ca_country, _s8.ca_state, _s8.ca_county, item.i_item_id + -> Sort (cost=666335.05..666335.94 rows=354 width=328) (actual time=12201.277..12276.129 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=656075.03..666320.07 rows=354 width=328) (actual time=12155.036..12254.975 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.014..12.131 rows=102000 loops=1) + -> Hash (cost=656070.60..656070.60 rows=354 width=319) (actual time=12154.984..12229.831 rows=14405 loops=1) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 2720kB + -> Subquery Scan on _s8 (cost=656000.17..656070.60 rows=354 width=319) (actual time=12137.171..12226.800 rows=14405 loops=1) + -> GroupAggregate (cost=656000.17..656067.06 rows=354 width=319) (actual time=12137.169..12226.015 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=656000.17..656041.40 rows=354 width=84) (actual time=12137.137..12214.561 rows=14405 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=655000.14..655000.51 rows=148 width=84) (actual time=12126.220..12126.386 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: 729kB + Worker 0: Sort Method: quicksort Memory: 927kB + Worker 1: Sort Method: quicksort Memory: 547kB + -> Parallel Hash Join (cost=648626.30..654994.81 rows=148 width=84) (actual time=12066.622..12121.416 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=15195 width=39) (actual time=0.246..53.125 rows=12282 loops=3) + Filter: ((ca_state)::text = ANY ('{MS,IN,ND,OK,NM,VA}'::text[])) + Rows Removed by Filter: 71052 + -> Parallel Hash (cost=648613.66..648613.66 rows=1011 width=61) (actual time=12066.242..12066.251 rows=32138 loops=3) + Buckets: 131072 (originally 4096) Batches: 1 (originally 1) Memory Usage: 11840kB + -> Parallel Hash Join (cost=632717.19..648613.66 rows=1011 width=61) (actual time=11859.177..12059.505 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=99847 width=24) (actual time=0.209..191.209 rows=79880 loops=3) + Filter: (c_birth_month = ANY ('{1,2,6,8,9,12}'::bigint[])) + Rows Removed by Filter: 86787 + -> Parallel Hash (cost=632690.69..632690.69 rows=2120 width=53) (actual time=11858.928..11858.935 rows=67467 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 23008kB + -> Parallel Hash Join (cost=597389.31..632690.69 rows=2120 width=53) (actual time=11315.781..11820.957 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=57482 width=16) (actual time=0.226..337.080 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=597018.46..597018.46 rows=29668 width=53) (actual time=10959.367..10959.371 rows=950367 loops=3) + Buckets: 65536 (originally 131072) Batches: 64 (originally 1) Memory Usage: 4896kB + -> Parallel Hash Join (cost=2571.80..597018.46 rows=29668 width=53) (actual time=1505.120..10666.884 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..571766.37 rows=6001437 width=61) (actual time=0.122..10166.590 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=1.527..1.528 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=2.221..4.531 rows=365 loops=1) + Filter: (d_year = 1998) + Rows Removed by Filter: 72684 +Planning Time: 0.391 ms +JIT: + Functions: 154 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.243 ms, Inlining 74.380 ms, Optimization 581.909 ms, Emission 379.309 ms, Total 1041.841 ms +Execution Time: 12684.985 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",13.870844832999865,14.150067407999813,"Limit (cost=872452.94..872453.19 rows=100 width=77) (actual time=13916.543..13917.401 rows=100 loops=1) + -> Sort (cost=872452.94..872453.41 rows=190 width=77) (actual time=13659.806..13660.659 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=871952.43..872445.74 rows=190 width=77) (actual time=13570.686..13660.360 rows=936 loops=1) + Group Key: i.i_brand, i.i_brand_id, i.i_manufact_id, i.i_manufact + -> Nested Loop (cost=871952.43..872440.99 rows=190 width=51) (actual time=13570.530..13658.985 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=871952.43..871975.72 rows=200 width=65) (actual time=13570.481..13573.724 rows=15767 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=870952.40..870952.61 rows=83 width=65) (actual time=13559.992..13560.176 rows=5256 loops=3) + Sort Key: i.i_brand, i.i_brand_id, i.i_manufact_id, i.i_manufact + Sort Method: quicksort Memory: 678kB + Worker 0: Sort Method: quicksort Memory: 630kB + Worker 1: Sort Method: quicksort Memory: 793kB + -> Parallel Hash Join (cost=865029.11..870949.76 rows=83 width=65) (actual time=13502.757..13554.392 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.262..44.906 rows=83333 loops=3) + -> Parallel Hash (cost=865028.08..865028.08 rows=83 width=67) (actual time=13502.341..13502.347 rows=5256 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1944kB + -> Parallel Hash Join (cost=850291.14..865028.08 rows=83 width=67) (actual time=13303.404..13495.619 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.171..178.335 rows=166667 loops=3) + -> Parallel Hash (cost=850290.04..850290.04 rows=88 width=67) (actual time=13303.038..13303.043 rows=5387 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1976kB + -> Parallel Hash Join (cost=7721.94..850290.04 rows=88 width=67) (actual time=235.774..12929.334 rows=5387 loops=3) + Hash Cond: (ss.ss_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2676.78..845226.93 rows=4690 width=30) (actual time=3.135..12675.204 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..797525.83 rows=11998983 width=38) (actual time=0.212..12279.554 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=2.447..2.448 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=18 width=8) (actual time=1.620..2.409 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=793 width=53) (actual time=232.398..232.399 rows=612 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 240kB + -> Parallel Seq Scan on item i (cost=0.00..5035.25 rows=793 width=53) (actual time=151.557..159.605 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.003 rows=102 loops=15767) + -> Seq Scan on store s (cost=0.00..6.02 rows=102 width=14) (actual time=0.016..0.045 rows=102 loops=1) +Planning Time: 0.501 ms +JIT: + Functions: 129 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.818 ms, Inlining 63.244 ms, Optimization 395.088 ms, Emission 253.180 ms, Total 716.329 ms +Execution Time: 13919.662 ms","Limit (cost=872452.94..872453.19 rows=100 width=77) (actual time=13907.999..13908.840 rows=100 loops=1) + -> Sort (cost=872452.94..872453.41 rows=190 width=77) (actual time=13658.431..13659.267 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=871952.43..872445.74 rows=190 width=77) (actual time=13568.714..13658.943 rows=936 loops=1) + Group Key: item.i_brand_id, item.i_brand, item.i_manufact_id, item.i_manufact + -> Nested Loop (cost=871952.43..872440.99 rows=190 width=51) (actual time=13568.615..13657.540 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=871952.43..871975.72 rows=200 width=65) (actual time=13568.582..13571.609 rows=15767 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=870952.40..870952.61 rows=83 width=65) (actual time=13558.053..13558.238 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: 678kB + Worker 0: Sort Method: quicksort Memory: 641kB + Worker 1: Sort Method: quicksort Memory: 794kB + -> Parallel Hash Join (cost=865029.11..870949.76 rows=83 width=65) (actual time=13508.545..13555.310 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.185..39.928 rows=83333 loops=3) + -> Parallel Hash (cost=865028.08..865028.08 rows=83 width=67) (actual time=13508.209..13508.215 rows=5256 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1944kB + -> Parallel Hash Join (cost=850291.14..865028.08 rows=83 width=67) (actual time=13315.219..13502.389 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.185..173.267 rows=166667 loops=3) + -> Parallel Hash (cost=850290.04..850290.04 rows=88 width=67) (actual time=13314.811..13314.816 rows=5387 loops=3) + Buckets: 16384 (originally 1024) Batches: 1 (originally 1) Memory Usage: 1976kB + -> Parallel Hash Join (cost=7721.94..850290.04 rows=88 width=67) (actual time=234.896..12952.324 rows=5387 loops=3) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> Parallel Hash Join (cost=2676.78..845226.93 rows=4690 width=30) (actual time=3.102..12699.313 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..797525.83 rows=11998983 width=38) (actual time=0.216..12324.841 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=2.394..2.395 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 72kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=18 width=8) (actual time=1.590..2.351 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=793 width=53) (actual time=231.485..231.486 rows=612 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 208kB + -> Parallel Seq Scan on item (cost=0.00..5035.25 rows=793 width=53) (actual time=150.448..158.600 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.003 rows=102 loops=15767) + -> Seq Scan on store (cost=0.00..6.02 rows=102 width=14) (actual time=0.014..0.045 rows=102 loops=1) +Planning Time: 0.536 ms +JIT: + Functions: 129 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.895 ms, Inlining 63.992 ms, Optimization 388.580 ms, Emission 248.399 ms, Total 705.866 ms +Execution Time: 13911.105 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.451211415000216,19.049852600999657,"Limit (cost=603679.40..603679.65 rows=100 width=203) (actual time=9434.366..9436.344 rows=100 loops=1) + -> Sort (cost=603679.40..603683.87 rows=1789 width=203) (actual time=9250.768..9252.742 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=603570.77..603611.02 rows=1789 width=203) (actual time=9242.516..9249.888 rows=14107 loops=1) + -> Sort (cost=603570.77..603575.24 rows=1789 width=171) (actual time=9242.416..9244.853 rows=14107 loops=1) + Sort Key: i.i_class + Sort Method: quicksort Memory: 2811kB + -> Finalize GroupAggregate (cost=603231.35..603474.12 rows=1789 width=171) (actual time=9221.589..9239.611 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=603231.35..603425.68 rows=1490 width=171) (actual time=9221.569..9233.288 rows=14107 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=602231.32..602253.67 rows=745 width=171) (actual time=9207.893..9211.818 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=602231.32..602233.19 rows=745 width=145) (actual time=9207.867..9208.327 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: 2719kB + Worker 0: Sort Method: quicksort Memory: 2335kB + Worker 1: Sort Method: quicksort Memory: 3078kB + -> Parallel Hash Join (cost=596994.92..602195.78 rows=745 width=145) (actual time=9169.118..9186.638 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=12501 width=147) (actual time=0.043..15.545 rows=10145 loops=3) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 23855 + -> Parallel Hash (cost=596963.24..596963.24 rows=2534 width=14) (actual time=9168.951..9168.954 rows=45386 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 10528kB + -> Parallel Hash Join (cost=2676.78..596963.24 rows=2534 width=14) (actual time=9052.234..9158.436 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..571766.37 rows=6001437 width=22) (actual time=0.627..8848.961 rows=4800420 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=18 width=8) (actual time=1.519..1.520 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.206..4.545 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.224 ms +JIT: + Functions: 93 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.765 ms, Inlining 79.788 ms, Optimization 289.803 ms, Emission 186.545 ms, Total 559.901 ms +Execution Time: 9438.159 ms","Limit (cost=1455855.87..1455856.12 rows=100 width=200) (actual time=18949.604..18949.620 rows=100 loops=1) + CTE _t3 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=31 width=12) (actual time=1.724..3.410 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=1452728.14..1452803.14 rows=30002 width=200) (actual time=18660.162..18660.171 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=1450756.43..1451581.48 rows=30002 width=200) (actual time=18652.172..18657.876 rows=14107 loops=1) + -> Sort (cost=1450756.43..1450831.43 rows=30002 width=192) (actual time=18652.102..18652.576 rows=14107 loops=1) + Sort Key: _t0.anything_i_class + Sort Method: quicksort Memory: 2804kB + -> Subquery Scan on _t0 (cost=1443895.80..1445753.36 rows=30002 width=192) (actual time=18635.146..18649.052 rows=14107 loops=1) + -> GroupAggregate (cost=1443895.80..1445453.34 rows=30002 width=200) (actual time=18635.143..18648.343 rows=14107 loops=1) + Group Key: item.i_item_sk + -> Sort (cost=1443895.80..1444043.61 rows=59126 width=153) (actual time=18635.116..18637.802 rows=40709 loops=1) + Sort Key: item.i_item_sk + Sort Method: external merge Disk: 6608kB + -> Hash Right Join (cost=720835.43..1434558.12 rows=59126 width=153) (actual time=18547.924..18624.816 rows=40709 loops=1) + Hash Cond: (catalog_sales.cs_item_sk = item.i_item_sk) + -> Hash Join (cost=1.01..712223.69 rows=242327 width=14) (actual time=9325.170..9393.469 rows=136158 loops=1) + Hash Cond: (catalog_sales.cs_sold_date_sk = _t4.d_date_sk) + -> Seq Scan on catalog_sales (cost=0.00..655786.48 rows=14403448 width=22) (actual time=0.005..8916.850 rows=14401261 loops=1) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=0.017..0.018 rows=31 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 10kB + -> CTE Scan on _t3 _t4 (cost=0.00..0.62 rows=31 width=8) (actual time=0.004..0.006 rows=31 loops=1) + -> Hash (cost=720523.33..720523.33 rows=24888 width=147) (actual time=9218.954..9218.957 rows=14107 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 2794kB + -> Hash Join (cost=719111.03..720523.33 rows=24888 width=147) (actual time=9207.056..9217.003 rows=14107 loops=1) + Hash Cond: (catalog_sales_1.cs_item_sk = item.i_item_sk) + -> HashAggregate (cost=712829.51..713675.62 rows=84612 width=8) (actual time=9180.149..9182.766 rows=47342 loops=1) + Group Key: catalog_sales_1.cs_item_sk + Batches: 1 Memory Usage: 5137kB + -> Hash Join (cost=1.01..712223.69 rows=242327 width=8) (actual time=9086.029..9167.806 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..655786.48 rows=14403448 width=16) (actual time=0.029..8707.570 rows=14401261 loops=1) + Filter: (cs_item_sk IS NOT NULL) + -> Hash (cost=0.62..0.62 rows=31 width=8) (actual time=3.422..3.423 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=1.729..3.418 rows=31 loops=1) + -> Hash (cost=5906.50..5906.50 rows=30002 width=147) (actual time=26.893..26.893 rows=30436 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 5754kB + -> Seq Scan on item (cost=0.00..5906.50 rows=30002 width=147) (actual time=0.018..23.594 rows=30436 loops=1) + Filter: ((i_category)::text = ANY ('{Sports,Books,Home}'::text[])) + Rows Removed by Filter: 71564 +Planning Time: 0.312 ms +JIT: + Functions: 58 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.316 ms, Inlining 9.067 ms, Optimization 167.843 ms, Emission 112.652 ms, Total 291.877 ms +Execution Time: 18952.794 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.378240118000576,19.567928284999653,"Limit (cost=1747031.29..1747167.24 rows=100 width=151) (actual time=19335.087..19341.595 rows=100 loops=1) + -> Finalize GroupAggregate (cost=1747031.29..1748150.18 rows=823 width=151) (actual time=19186.977..19193.479 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=1747031.29..1747829.07 rows=6176 width=151) (actual time=19186.943..19193.384 rows=460 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1746031.26..1746116.18 rows=3088 width=151) (actual time=19146.889..19147.281 rows=542 loops=3) + Group Key: w.w_warehouse_name, i.i_item_id + -> Sort (cost=1746031.26..1746038.98 rows=3088 width=143) (actual time=19146.847..19147.066 rows=1546 loops=3) + Sort Key: w.w_warehouse_name, i.i_item_id + Sort Method: external merge Disk: 4736kB + Worker 0: Sort Method: external merge Disk: 5328kB + Worker 1: Sort Method: external merge Disk: 4456kB + -> Hash Join (cost=7865.05..1745852.28 rows=3088 width=143) (actual time=7931.423..18966.579 rows=96780 loops=3) + Hash Cond: (inv.inv_warehouse_sk = w.w_warehouse_sk) + -> Parallel Hash Join (cost=7852.80..1745797.57 rows=3088 width=33) (actual time=7792.061..18817.578 rows=96780 loops=3) + Hash Cond: (inv.inv_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2677.01..1740429.56 rows=47830 width=24) (actual time=7784.899..18709.350 rows=1530000 loops=3) + Hash Cond: (inv.inv_date_sk = d.d_date_sk) + -> Parallel Seq Scan on inventory inv (cost=0.00..1529500.83 rows=55458883 width=28) (actual time=0.201..16768.532 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=37 width=12) (actual time=1.090..1.091 rows=20 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=37 width=12) (actual time=1.648..3.262 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=2743 width=25) (actual time=7.018..7.018 rows=2155 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 480kB + -> Parallel Seq Scan on item i (cost=0.00..5141.50 rows=2743 width=25) (actual time=0.039..20.264 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=139.337..139.337 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=139.319..139.322 rows=10 loops=3) +Planning Time: 0.254 ms +JIT: + Functions: 113 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.697 ms, Inlining 102.336 ms, Optimization 270.948 ms, Emission 192.964 ms, Total 569.945 ms +Execution Time: 19343.866 ms","Limit (cost=1748189.87..1748190.12 rows=100 width=151) (actual time=19369.627..19373.700 rows=100 loops=1) + -> Sort (cost=1748189.87..1748191.92 rows=823 width=151) (actual time=19210.180..19214.248 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=1747031.29..1748158.41 rows=823 width=151) (actual time=19153.567..19211.364 rows=16926 loops=1) + -> Finalize GroupAggregate (cost=1747031.29..1748150.18 rows=823 width=151) (actual time=19153.564..19210.426 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=1747031.29..1747829.07 rows=6176 width=151) (actual time=19153.537..19199.810 rows=85782 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1746031.26..1746116.18 rows=3088 width=151) (actual time=19124.680..19147.494 rows=28594 loops=3) + Group Key: item.i_item_id, warehouse.w_warehouse_name + -> Sort (cost=1746031.26..1746038.98 rows=3088 width=143) (actual time=19124.645..19136.028 rows=87102 loops=3) + Sort Key: item.i_item_id, warehouse.w_warehouse_name + Sort Method: external merge Disk: 5400kB + Worker 0: Sort Method: external merge Disk: 3928kB + Worker 1: Sort Method: external merge Disk: 4104kB + -> Hash Join (cost=7865.05..1745852.28 rows=3088 width=143) (actual time=7907.601..18972.881 rows=87102 loops=3) + Hash Cond: (inventory.inv_warehouse_sk = warehouse.w_warehouse_sk) + -> Parallel Hash Join (cost=7852.80..1745797.57 rows=3088 width=33) (actual time=7761.526..18817.981 rows=96780 loops=3) + Hash Cond: (inventory.inv_item_sk = item.i_item_sk) + -> Parallel Hash Join (cost=2677.01..1740429.56 rows=47830 width=24) (actual time=7754.584..18712.327 rows=1530000 loops=3) + Hash Cond: (inventory.inv_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on inventory (cost=0.00..1529500.83 rows=55458883 width=28) (actual time=0.166..16806.036 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=37 width=12) (actual time=1.069..1.070 rows=20 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=37 width=12) (actual time=1.611..3.198 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=2743 width=25) (actual time=6.734..6.735 rows=2155 loops=3) + Buckets: 8192 Batches: 1 Memory Usage: 480kB + -> Parallel Seq Scan on item (cost=0.00..5141.50 rows=2743 width=25) (actual time=0.036..19.443 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=146.042..146.043 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=146.027..146.031 rows=9 loops=3) + Filter: (w_warehouse_name IS NOT NULL) + Rows Removed by Filter: 1 +Planning Time: 0.309 ms +JIT: + Functions: 120 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.851 ms, Inlining 102.430 ms, Optimization 288.498 ms, Emission 206.752 ms, Total 601.532 ms +Execution Time: 19375.993 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",49.90988358499999,20.755374403000133,"Limit (cost=1820837.87..1820838.12 rows=100 width=83) (actual time=54112.512..54149.138 rows=100 loops=1) + -> Sort (cost=1820837.87..1821092.26 rows=101755 width=83) (actual time=53963.761..54000.381 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=1784514.32..1816948.87 rows=101755 width=83) (actual time=50852.916..53985.876 rows=67967 loops=1) + Group Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + -> Gather Merge (cost=1784514.32..1813133.05 rows=203510 width=83) (actual time=50852.851..53932.427 rows=203901 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1783514.30..1788642.93 rows=101755 width=83) (actual time=49474.168..52130.131 rows=67967 loops=3) + Group Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + -> Sort (cost=1783514.30..1784199.48 rows=274072 width=55) (actual time=49474.089..51202.917 rows=8840000 loops=3) + Sort Key: i.i_product_name, i.i_brand, i.i_class, i.i_category + Sort Method: external merge Disk: 788912kB + Worker 0: Sort Method: external merge Disk: 480720kB + Worker 1: Sort Method: external merge Disk: 511832kB + -> Parallel Hash Join (cost=8139.45..1749390.34 rows=274072 width=55) (actual time=4430.816..19475.935 rows=8840000 loops=3) + Hash Cond: (inv.inv_item_sk = i.i_item_sk) + -> Parallel Hash Join (cost=2679.20..1741760.35 rows=274072 width=12) (actual time=4253.269..18123.456 rows=8840000 loops=3) + Hash Cond: (inv.inv_date_sk = d.d_date_sk) + -> Parallel Seq Scan on inventory inv (cost=0.00..1529500.83 rows=55458883 width=20) (actual time=0.240..15768.392 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=212 width=8) (actual time=2.276..2.278 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2676.55 rows=212 width=8) (actual time=1.137..2.227 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=177.075..177.076 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=110.449..119.115 rows=34000 loops=3) +Planning Time: 1.034 ms +JIT: + Functions: 79 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.981 ms, Inlining 98.060 ms, Optimization 230.179 ms, Emission 152.044 ms, Total 484.264 ms +Execution Time: 54226.358 ms","Limit (cost=1825828.53..1825828.78 rows=100 width=59) (actual time=21012.662..21012.896 rows=100 loops=1) + -> Sort (cost=1825828.53..1826037.04 rows=83403 width=59) (actual time=20854.966..20855.195 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=1819304.81..1822640.93 rows=83403 width=59) (actual time=20808.091..20848.352 rows=67967 loops=1) + Group Key: item.i_product_name, item.i_brand, item.i_class, item.i_category + -> Sort (cost=1819304.81..1819513.32 rows=83403 width=67) (actual time=20808.046..20822.602 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=1780096.33..1809064.53 rows=83403 width=67) (actual time=19569.450..20703.150 rows=68000 loops=1) + Hash Cond: (_s2.inv_item_sk = item.i_item_sk) + -> Subquery Scan on _s2 (cost=1772201.33..1797948.74 rows=83403 width=24) (actual time=19532.494..20642.030 rows=68000 loops=1) + -> Finalize GroupAggregate (cost=1772201.33..1797114.71 rows=83403 width=24) (actual time=19532.490..20637.839 rows=68000 loops=1) + Group Key: inventory.inv_item_sk + -> Gather Merge (cost=1772201.33..1795029.63 rows=166806 width=24) (actual time=19532.439..20619.354 rows=204000 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=1771201.31..1774776.06 rows=83403 width=24) (actual time=19459.242..20404.603 rows=68000 loops=3) + Group Key: inventory.inv_item_sk + -> Sort (cost=1771201.31..1771886.49 rows=274072 width=12) (actual time=19459.186..19999.975 rows=8840000 loops=3) + Sort Key: inventory.inv_item_sk + Sort Method: external merge Disk: 192944kB + Worker 0: Sort Method: external merge Disk: 187944kB + Worker 1: Sort Method: external merge Disk: 184992kB + -> Parallel Hash Join (cost=2679.20..1741760.35 rows=274072 width=12) (actual time=4204.509..18035.001 rows=8840000 loops=3) + Hash Cond: (inventory.inv_date_sk = date_dim.d_date_sk) + -> Parallel Seq Scan on inventory (cost=0.00..1529500.83 rows=55458883 width=20) (actual time=0.124..15725.398 rows=44370000 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=212 width=8) (actual time=1.176..1.177 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=212 width=8) (actual time=1.809..3.456 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=36.809..36.810 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.017..24.925 rows=102000 loops=1) +Planning Time: 0.223 ms +JIT: + Functions: 69 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 2.705 ms, Inlining 91.283 ms, Optimization 161.711 ms, Emission 113.503 ms, Total 369.202 ms +Execution Time: 21038.322 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.16009461900012,9.980045934999907,"Limit (cost=50011.69..265609.80 rows=100 width=145) (actual time=9346.418..10381.756 rows=100 loops=1) + -> GroupAggregate (cost=50011.69..2139157.34 rows=969 width=145) (actual time=9337.788..10373.116 rows=100 loops=1) + Group Key: i.i_item_id + -> Nested Loop (cost=50011.69..2139125.85 rows=969 width=40) (actual time=2783.097..10372.930 rows=142 loops=1) + Join Filter: (cs.cs_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 18260029 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=102.639..107.550 rows=469 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=65.720..65.761 rows=861 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 1972kB + Worker 1: Sort Method: quicksort Memory: 2276kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=1.272..9.126 rows=34000 loops=3) + -> Materialize (cost=40815.45..635482.44 rows=969 width=31) (actual time=3.917..20.634 rows=38934 loops=469) + -> Gather (cost=40815.45..635477.60 rows=969 width=31) (actual time=1836.854..9218.857 rows=39015 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Hash Join (cost=39815.45..634380.70 rows=404 width=31) (actual time=1833.656..9210.439 rows=13005 loops=3) + Hash Cond: (cs.cs_promo_sk = p.p_promo_sk) + -> Parallel Hash Join (cost=39790.86..634350.51 rows=417 width=39) (actual time=1828.613..9203.788 rows=13324 loops=3) + Hash Cond: (cs.cs_bill_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..597018.46 rows=29668 width=47) (actual time=1475.730..8805.623 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..571766.37 rows=6001437 width=55) (actual time=0.109..8516.445 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.485..2.486 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=214 width=8) (actual time=1.238..2.424 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=352.462..352.463 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11298 width=8) (actual time=0.223..351.052 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=4.959..4.960 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=4.856..4.923 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.286 ms +JIT: + Functions: 104 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.765 ms, Inlining 0.000 ms, Optimization 1.862 ms, Emission 25.047 ms, Total 30.674 ms +Execution Time: 10383.936 ms","Limit (cost=641431.92..641432.17 rows=100 width=49) (actual time=9780.571..9781.120 rows=100 loops=1) + -> Sort (cost=641431.92..641434.34 rows=969 width=49) (actual time=9604.494..9605.038 rows=100 loops=1) + Sort Key: item.i_item_id NULLS FIRST + Sort Method: top-N heapsort Memory: 48kB + -> Hash Join (cost=635574.06..641394.89 rows=969 width=49) (actual time=9566.681..9599.054 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.009..9.820 rows=102000 loops=1) + -> Hash (cost=635561.94..635561.94 rows=969 width=168) (actual time=9566.641..9567.181 rows=27461 loops=1) + Buckets: 32768 (originally 1024) Batches: 1 (originally 1) Memory Usage: 3046kB + -> Subquery Scan on _s6 (cost=635398.21..635561.94 rows=969 width=168) (actual time=9541.541..9563.892 rows=27461 loops=1) + -> GroupAggregate (cost=635398.21..635552.25 rows=969 width=168) (actual time=9541.539..9562.460 rows=27461 loops=1) + Group Key: catalog_sales.cs_item_sk + -> Gather Merge (cost=635398.21..635511.07 rows=969 width=31) (actual time=9541.484..9546.566 rows=39015 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=634398.19..634399.20 rows=404 width=31) (actual time=9531.038..9532.309 rows=13005 loops=3) + Sort Key: catalog_sales.cs_item_sk + Sort Method: quicksort Memory: 1185kB + Worker 0: Sort Method: quicksort Memory: 1205kB + Worker 1: Sort Method: quicksort Memory: 1199kB + -> Hash Join (cost=39815.45..634380.70 rows=404 width=31) (actual time=1897.224..9529.035 rows=13005 loops=3) + Hash Cond: (catalog_sales.cs_promo_sk = promotion.p_promo_sk) + -> Parallel Hash Join (cost=39790.86..634350.51 rows=417 width=39) (actual time=1796.641..9426.965 rows=13324 loops=3) + Hash Cond: (catalog_sales.cs_bill_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..597018.46 rows=29668 width=47) (actual time=1570.151..9157.702 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..571766.37 rows=6001437 width=55) (actual time=0.114..8911.889 rows=4800420 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.088..2.089 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=1.047..2.036 rows=122 loops=3) + Filter: (d_year = 2000) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=226.041..226.042 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1408kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11298 width=8) (actual time=0.335..224.475 rows=9147 loops=3) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 631120 + -> Hash (cost=18.50..18.50 rows=487 width=8) (actual time=100.551..100.552 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=100.434..100.508 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.262 ms +JIT: + Functions: 104 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 3.669 ms, Inlining 76.218 ms, Optimization 244.605 ms, Emission 156.713 ms, Total 481.206 ms +Execution Time: 9783.080 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.076046764999774,14.051356692000809,"Limit (cost=52073.65..260600.02 rows=100 width=152) (actual time=13664.646..14309.527 rows=100 loops=1) + -> GroupAggregate (cost=52073.65..3265465.02 rows=1541 width=152) (actual time=13654.248..14299.123 rows=100 loops=1) + Group Key: i.i_item_id, s.s_state + -> Incremental Sort (cost=52073.65..3265407.24 rows=1541 width=43) (actual time=13654.221..14299.002 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=49987.11..3265337.89 rows=1541 width=43) (actual time=13451.664..14298.941 rows=129 loops=1) + Join Filter: (ss.ss_item_sk = i.i_item_sk) + Rows Removed by Join Filter: 14753717 + -> Gather Merge (cost=9196.25..21075.83 rows=102000 width=25) (actual time=78.613..85.810 rows=590 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=8196.22..8302.47 rows=42500 width=25) (actual time=64.940..64.987 rows=881 loops=3) + Sort Key: i.i_item_id + Sort Method: external merge Disk: 2168kB + Worker 0: Sort Method: quicksort Memory: 2124kB + Worker 1: Sort Method: quicksort Memory: 2124kB + -> Parallel Seq Scan on item i (cost=0.00..4929.00 rows=42500 width=25) (actual time=1.537..8.701 rows=34000 loops=3) + -> Materialize (cost=40790.86..886535.92 rows=1541 width=34) (actual time=0.588..23.283 rows=25007 loops=590) + -> Nested Loop (cost=40790.86..886528.21 rows=1541 width=34) (actual time=347.189..13364.679 rows=25041 loops=1) + Join Filter: (ss.ss_store_sk = s.s_store_sk) + Rows Removed by Join Filter: 2327921 + -> Gather (cost=40790.86..884046.65 rows=1833 width=39) (actual time=344.127..13214.680 rows=75902 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=39790.86..882863.35 rows=764 width=39) (actual time=336.142..13304.453 rows=25301 loops=3) + Hash Cond: (ss.ss_cdemo_sk = cd.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..845428.33 rows=56742 width=47) (actual time=3.005..12878.729 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..797525.83 rows=11998983 width=55) (actual time=0.186..12259.980 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.657..2.657 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=214 width=8) (actual time=1.347..2.581 rows=122 loops=3) + Filter: (d_year = 2002) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=330.358..330.359 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics cd (cost=0.00..37077.83 rows=11298 width=8) (actual time=3.815..328.790 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.001 rows=31 loops=75902) + -> Seq Scan on store s (cost=0.00..6.79 rows=90 width=11) (actual time=0.015..0.050 rows=31 loops=1) + Filter: ((s_state)::text = ANY ('{TN,TN,TN,TN,TN,TN}'::text[])) + Rows Removed by Filter: 71 +Planning Time: 0.317 ms +JIT: + Functions: 87 + Options: Inlining false, Optimization false, Expressions true, Deforming true + Timing: Generation 3.298 ms, Inlining 0.000 ms, Optimization 1.691 ms, Emission 24.303 ms, Total 29.291 ms +Execution Time: 14311.846 ms","Limit (cost=890803.77..890812.52 rows=100 width=56) (actual time=13832.487..13833.142 rows=100 loops=1) + -> GroupAggregate (cost=890803.77..890850.24 rows=531 width=56) (actual time=13598.352..13599.003 rows=100 loops=1) + Group Key: item.i_item_id, store.s_state + -> Sort (cost=890803.77..890805.10 rows=531 width=180) (actual time=13598.322..13598.855 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=890682.72..890779.74 rows=531 width=180) (actual time=13546.562..13567.217 rows=19773 loops=1) + Hash Cond: (store_sales.ss_item_sk = item.i_item_sk) + -> GroupAggregate (cost=883883.72..883968.13 rows=531 width=171) (actual time=13522.030..13537.014 rows=19773 loops=1) + Group Key: store_sales.ss_item_sk + -> Gather Merge (cost=883883.72..883945.56 rows=531 width=34) (actual time=13521.978..13525.578 rows=25041 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=882883.69..882884.25 rows=221 width=34) (actual time=13511.548..13512.350 rows=8347 loops=3) + Sort Key: store_sales.ss_item_sk + Sort Method: quicksort Memory: 931kB + Worker 0: Sort Method: quicksort Memory: 918kB + Worker 1: Sort Method: quicksort Memory: 711kB + -> Hash Join (cost=39797.52..882875.09 rows=221 width=34) (actual time=324.010..13510.025 rows=8347 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=39790.86..882863.35 rows=764 width=39) (actual time=188.602..13373.862 rows=25301 loops=3) + Hash Cond: (store_sales.ss_cdemo_sk = customer_demographics.cd_demo_sk) + -> Parallel Hash Join (cost=2571.80..845428.33 rows=56742 width=47) (actual time=2.616..13098.462 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..797525.83 rows=11998983 width=55) (actual time=0.166..12535.617 rows=9600330 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.300..2.301 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 104kB + -> Parallel Seq Scan on date_dim (cost=0.00..2569.12 rows=214 width=8) (actual time=1.155..2.232 rows=122 loops=3) + Filter: (d_year = 2002) + Rows Removed by Filter: 24228 + -> Parallel Hash (cost=37077.83..37077.83 rows=11298 width=8) (actual time=182.768..182.769 rows=9147 loops=3) + Buckets: 32768 Batches: 1 Memory Usage: 1376kB + -> Parallel Seq Scan on customer_demographics (cost=0.00..37077.83 rows=11298 width=8) (actual time=0.401..181.087 rows=9147 loops=3) + Filter: (((cd_education_status)::text = 'College'::text) AND ((cd_gender)::text = 'M'::text) AND ((cd_marital_status)::text = 'S'::text)) + Rows Removed by Filter: 631120 + -> Hash (cost=6.28..6.28 rows=31 width=11) (actual time=134.297..134.298 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=134.246..134.287 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=24.499..24.500 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.014..17.149 rows=102000 loops=1) +Planning Time: 0.268 ms +JIT: + Functions: 110 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.301 ms, Inlining 78.369 ms, Optimization 339.233 ms, Emission 219.375 ms, Total 641.277 ms +Execution Time: 13835.400 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.1260717770001,80.18928681299985,"Limit (cost=6550855.99..6550856.10 rows=1 width=288) (actual time=79897.180..79904.866 rows=1 loops=1) + -> Nested Loop (cost=6550855.99..6550856.10 rows=1 width=288) (actual time=79576.184..79583.869 rows=1 loops=1) + -> Nested Loop (cost=5465753.86..5465753.95 rows=1 width=240) (actual time=66287.418..66287.745 rows=1 loops=1) + -> Nested Loop (cost=4371684.07..4371684.14 rows=1 width=192) (actual time=53013.965..53014.231 rows=1 loops=1) + -> Nested Loop (cost=3284917.30..3284917.35 rows=1 width=144) (actual time=39691.107..39691.306 rows=1 loops=1) + -> Nested Loop (cost=2197878.11..2197878.14 rows=1 width=96) (actual time=26429.891..26430.038 rows=1 loops=1) + -> Aggregate (cost=1102118.97..1102118.98 rows=1 width=48) (actual time=13113.729..13113.823 rows=1 loops=1) + -> Gather Merge (cost=1054521.41..1099239.30 rows=383955 width=6) (actual time=13049.355..13090.622 rows=367014 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1053521.39..1053921.34 rows=159981 width=6) (actual time=13039.485..13047.616 rows=122338 loops=3) + Sort Key: store_sales.ss_list_price + Sort Method: external merge Disk: 1344kB + Worker 0: Sort Method: external merge Disk: 1296kB + Worker 1: Sort Method: external merge Disk: 1304kB + -> Parallel Seq Scan on store_sales (cost=0.00..1037505.50 rows=159981 width=6) (actual time=62.415..13011.574 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=1095759.14..1095759.15 rows=1 width=48) (actual time=13316.155..13316.207 rows=1 loops=1) + -> Gather Merge (cost=1052840.83..1093162.57 rows=346209 width=6) (actual time=13257.198..13294.151 rows=355872 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1051840.81..1052201.44 rows=144254 width=6) (actual time=13241.480..13248.379 rows=118624 loops=3) + Sort Key: store_sales_1.ss_list_price + Sort Method: external sort Disk: 1776kB + Worker 0: Sort Method: external merge Disk: 1264kB + Worker 1: Sort Method: external merge Disk: 1256kB + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..1037505.50 rows=144254 width=6) (actual time=65.406..13212.875 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=1087039.19..1087039.20 rows=1 width=48) (actual time=13261.207..13261.259 rows=1 loops=1) + -> Gather Merge (cost=1049267.47..1084753.99 rows=304693 width=6) (actual time=13209.591..13241.968 rows=282365 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1048267.45..1048584.84 rows=126955 width=6) (actual time=13195.741..13198.638 rows=94122 loops=3) + Sort Key: store_sales_2.ss_list_price + Sort Method: quicksort Memory: 3958kB + Worker 0: Sort Method: quicksort Memory: 3902kB + Worker 1: Sort Method: quicksort Memory: 3909kB + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..1037505.50 rows=126955 width=6) (actual time=60.438..13173.358 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=1086766.77..1086766.78 rows=1 width=48) (actual time=13322.851..13322.916 rows=1 loops=1) + -> Gather Merge (cost=1049203.19..1084494.16 rows=303014 width=6) (actual time=13260.595..13299.701 rows=319172 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1048203.17..1048518.81 rows=126256 width=6) (actual time=13246.407..13252.807 rows=106391 loops=3) + Sort Key: store_sales_3.ss_list_price + Sort Method: external sort Disk: 1592kB + Worker 0: Sort Method: external merge Disk: 1136kB + Worker 1: Sort Method: external merge Disk: 1136kB + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..1037505.50 rows=126256 width=6) (actual time=59.776..13217.499 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=1094069.78..1094069.79 rows=1 width=48) (actual time=13273.445..13273.505 rows=1 loops=1) + -> Gather Merge (cost=1052396.47..1091548.54 rows=336166 width=6) (actual time=13205.476..13248.312 rows=365262 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1051396.44..1051746.62 rows=140069 width=6) (actual time=13187.515..13194.929 rows=121754 loops=3) + Sort Key: store_sales_4.ss_list_price + Sort Method: external sort Disk: 1832kB + Worker 0: Sort Method: external merge Disk: 1288kB + Worker 1: Sort Method: external merge Disk: 1296kB + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..1037505.50 rows=140069 width=6) (actual time=69.935..13158.028 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=1085102.13..1085102.14 rows=1 width=48) (actual time=13288.760..13296.118 rows=1 loops=1) + -> Gather Merge (cost=1048810.57..1082906.48 rows=292753 width=6) (actual time=13235.063..13276.115 rows=302090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1047810.54..1048115.49 rows=121980 width=6) (actual time=13220.941..13223.988 rows=100697 loops=3) + Sort Key: store_sales_5.ss_list_price + Sort Method: quicksort Memory: 4074kB + Worker 0: Sort Method: quicksort Memory: 4004kB + Worker 1: Sort Method: quicksort Memory: 3998kB + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..1037505.50 rows=121980 width=6) (actual time=59.579..13197.738 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.317 ms +JIT: + Functions: 90 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 8.659 ms, Inlining 431.725 ms, Optimization 616.873 ms, Emission 383.477 ms, Total 1440.734 ms +Execution Time: 79908.685 ms","Nested Loop (cost=9891300.55..9891300.66 rows=1 width=288) (actual time=79612.053..79618.092 rows=1 loops=1) + -> Nested Loop (cost=8259399.40..8259399.49 rows=1 width=240) (actual time=66324.172..66324.626 rows=1 loops=1) + -> Nested Loop (cost=6607266.22..6607266.29 rows=1 width=192) (actual time=53035.567..53035.947 rows=1 loops=1) + -> Nested Loop (cost=4953483.32..4953483.37 rows=1 width=144) (actual time=39743.009..39743.295 rows=1 loops=1) + -> Nested Loop (cost=3322776.71..3322776.74 rows=1 width=96) (actual time=26466.849..26467.069 rows=1 loops=1) + -> Aggregate (cost=1659047.78..1659047.79 rows=1 width=48) (actual time=13198.587..13198.736 rows=1 loops=1) + -> Gather Merge (cost=1599003.87..1655415.11 rows=484356 width=6) (actual time=13130.347..13173.878 rows=367014 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1598003.85..1598508.39 rows=201815 width=6) (actual time=13116.719..13124.845 rows=122338 loops=3) + Sort Key: store_sales.ss_list_price + Sort Method: external merge Disk: 1280kB + Worker 0: Sort Method: external merge Disk: 1328kB + Worker 1: Sort Method: external merge Disk: 1336kB + -> Parallel Seq Scan on store_sales (cost=0.00..1577459.75 rows=201815 width=6) (actual time=222.524..13087.924 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=1663728.93..1663728.94 rows=1 width=48) (actual time=13268.255..13268.323 rows=1 loops=1) + -> Gather Merge (cost=1600260.81..1659889.09 rows=511978 width=6) (actual time=13207.430..13246.153 rows=355872 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1599260.79..1599794.10 rows=213324 width=6) (actual time=13191.186..13197.425 rows=118624 loops=3) + Sort Key: store_sales_1.ss_list_price + Sort Method: external sort Disk: 1784kB + Worker 0: Sort Method: external merge Disk: 1256kB + Worker 1: Sort Method: external merge Disk: 1256kB + -> Parallel Seq Scan on store_sales store_sales_1 (cost=0.00..1577459.75 rows=213324 width=6) (actual time=67.117..13161.988 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=1630706.61..1630706.62 rows=1 width=48) (actual time=13276.152..13276.217 rows=1 loops=1) + -> Gather Merge (cost=1591478.65..1628333.31 rows=316440 width=6) (actual time=13222.662..13256.248 rows=282365 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1590478.63..1590808.25 rows=131850 width=6) (actual time=13207.363..13210.252 rows=94122 loops=3) + Sort Key: store_sales_2.ss_list_price + Sort Method: quicksort Memory: 3981kB + Worker 0: Sort Method: quicksort Memory: 3901kB + Worker 1: Sort Method: quicksort Memory: 3888kB + -> Parallel Seq Scan on store_sales store_sales_2 (cost=0.00..1577459.75 rows=131850 width=6) (actual time=87.777..13184.530 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=1653782.90..1653782.91 rows=1 width=48) (actual time=13292.549..13292.643 rows=1 loops=1) + -> Gather Merge (cost=1597593.48..1650383.43 rows=453263 width=6) (actual time=13234.077..13271.026 rows=319172 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1596593.46..1597065.61 rows=188860 width=6) (actual time=13219.309..13222.940 rows=106391 loops=3) + Sort Key: store_sales_3.ss_list_price + Sort Method: external sort Disk: 1600kB + Worker 0: Sort Method: quicksort Memory: 4087kB + Worker 1: Sort Method: quicksort Memory: 4093kB + -> Parallel Seq Scan on store_sales store_sales_3 (cost=0.00..1577459.75 rows=188860 width=6) (actual time=67.267..13178.958 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=1652133.18..1652133.19 rows=1 width=48) (actual time=13288.598..13288.669 rows=1 loops=1) + -> Gather Merge (cost=1597152.43..1648806.83 rows=443513 width=6) (actual time=13222.794..13264.207 rows=365262 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1596152.41..1596614.40 rows=184797 width=6) (actual time=13204.763..13212.232 rows=121754 loops=3) + Sort Key: store_sales_4.ss_list_price + Sort Method: external sort Disk: 1840kB + Worker 0: Sort Method: external merge Disk: 1296kB + Worker 1: Sort Method: external merge Disk: 1280kB + -> Parallel Seq Scan on store_sales store_sales_4 (cost=0.00..1577459.75 rows=184797 width=6) (actual time=68.928..13175.506 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=1631901.15..1631901.16 rows=1 width=48) (actual time=13287.871..13293.455 rows=1 loops=1) + -> Gather Merge (cost=1591790.93..1629474.47 rows=323557 width=6) (actual time=13232.526..13272.497 rows=302090 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=1590790.91..1591127.94 rows=134815 width=6) (actual time=13218.401..13221.495 rows=100697 loops=3) + Sort Key: store_sales_5.ss_list_price + Sort Method: quicksort Memory: 4063kB + Worker 0: Sort Method: quicksort Memory: 4012kB + Worker 1: Sort Method: quicksort Memory: 4001kB + -> Parallel Seq Scan on store_sales store_sales_5 (cost=0.00..1577459.75 rows=134815 width=6) (actual time=66.834..13195.665 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.578 ms +JIT: + Functions: 89 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 12.360 ms, Inlining 445.139 ms, Optimization 772.525 ms, Emission 517.787 ms, Total 1747.811 ms +Execution Time: 79623.054 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",24.698963146000096,23.932000263999726,"Limit (cost=937206.77..1534085.58 rows=1 width=236) (actual time=24134.420..25129.957 rows=8 loops=1) + -> GroupAggregate (cost=937206.77..1534085.58 rows=1 width=236) (actual time=23905.421..24900.955 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=937206.77..1534085.54 rows=1 width=164) (actual time=23604.731..24900.910 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=851714.09..852921.62 rows=10368 width=180) (actual time=13536.954..13842.244 rows=576541 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=850714.07..850724.87 rows=4320 width=180) (actual time=13476.731..13592.032 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: 50792kB + Worker 0: Sort Method: external merge Disk: 29912kB + Worker 1: Sort Method: external merge Disk: 29792kB + -> Parallel Hash Join (cost=845346.84..850453.21 rows=4320 width=180) (actual time=13063.003..13106.104 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.018..3.482 rows=34000 loops=3) + -> Parallel Hash (cost=845292.84..845292.84 rows=4320 width=53) (actual time=13045.922..13046.236 rows=192180 loops=3) + Buckets: 131072 (originally 16384) Batches: 8 (originally 1) Memory Usage: 7264kB + -> Hash Join (cost=2684.06..845292.84 rows=4320 width=53) (actual time=103.140..12960.410 rows=192180 loops=3) + Hash Cond: (ss.ss_store_sk = s.s_store_sk) + -> Parallel Hash Join (cost=2676.76..845225.35 rows=4533 width=40) (actual time=3.082..12840.335 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..797525.83 rows=11998983 width=48) (actual time=1.581..12445.744 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=17 width=8) (actual time=1.348..1.349 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d1 (cost=0.00..2676.55 rows=17 width=8) (actual time=2.127..4.036 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=100.045..100.045 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=100.000..100.022 rows=102 loops=3) + -> Materialize (cost=85492.68..680956.57 rows=1 width=56) (actual time=0.001..0.018 rows=37 loops=576541) + -> Gather (cost=85492.68..680956.56 rows=1 width=56) (actual time=291.541..9913.934 rows=37 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=84492.68..679956.46 rows=1 width=56) (actual time=525.196..9896.998 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.85..597426.49 rows=89085 width=24) (actual time=2.629..9393.104 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..571766.37 rows=6001437 width=32) (actual time=0.145..9061.017 rows=4800420 loops=3) + -> Parallel Hash (cost=2622.84..2622.84 rows=641 width=8) (actual time=2.447..2.448 rows=365 loops=3) + Buckets: 2048 Batches: 1 Memory Usage: 112kB + -> Parallel Seq Scan on date_dim d3 (cost=0.00..2622.84 rows=641 width=8) (actual time=1.225..2.380 rows=365 loops=3) + Filter: (d_year = ANY ('{1999,2000,2001}'::bigint[])) + Rows Removed by Filter: 23984 + -> Parallel Hash (cost=81833.32..81833.32 rows=1901 width=32) (actual time=265.849..265.852 rows=61011 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 15296kB + -> Parallel Hash Join (cost=2784.86..81833.32 rows=1901 width=32) (actual time=86.707..206.896 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.24 rows=1198924 width=40) (actual time=0.023..71.479 rows=959177 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=71 width=8) (actual time=1.387..1.388 rows=41 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d2 (cost=0.00..2783.97 rows=71 width=8) (actual time=2.205..4.144 rows=122 loops=1) + Filter: ((d_moy >= 9) AND (d_moy <= 15) AND (d_year = 1999)) + Rows Removed by Filter: 72927 +Planning Time: 3.193 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.289 ms, Inlining 149.757 ms, Optimization 382.212 ms, Emission 253.167 ms, Total 791.424 ms +Execution Time: 25134.417 ms","Limit (cost=937224.76..1534173.44 rows=1 width=236) (actual time=24170.879..25204.639 rows=8 loops=1) + -> GroupAggregate (cost=937224.76..1534173.44 rows=1 width=236) (actual time=23946.400..24980.159 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=937224.76..1534173.40 rows=1 width=164) (actual time=23621.106..24980.114 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=851732.08..852999.24 rows=10880 width=180) (actual time=13580.332..13935.582 rows=590381 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=850732.06..850743.39 rows=4533 width=180) (actual time=13507.845..13616.147 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: 29984kB + Worker 0: Sort Method: external merge Disk: 53040kB + Worker 1: Sort Method: external merge Disk: 29856kB + -> Hash Left Join (cost=845289.31..850456.76 rows=4533 width=180) (actual time=13076.210..13134.867 rows=196794 loops=3) + Hash Cond: (store_sales.ss_store_sk = store.s_store_sk) + -> Parallel Hash Join (cost=845282.01..850389.28 rows=4533 width=167) (actual time=13076.154..13115.807 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.013..3.495 rows=34000 loops=3) + -> Parallel Hash (cost=845225.35..845225.35 rows=4533 width=40) (actual time=13058.832..13058.835 rows=196794 loops=3) + Buckets: 131072 (originally 16384) Batches: 8 (originally 1) Memory Usage: 6240kB + -> Parallel Hash Join (cost=2676.76..845225.35 rows=4533 width=40) (actual time=96.400..12974.221 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..797525.83 rows=11998983 width=48) (actual time=0.008..12470.443 rows=9600330 loops=3) + -> Parallel Hash (cost=2676.55..2676.55 rows=17 width=8) (actual time=1.671..1.671 rows=10 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim (cost=0.00..2676.55 rows=17 width=8) (actual time=2.458..4.996 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.041..0.042 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.015..0.029 rows=102 loops=3) + -> Materialize (cost=85492.68..680956.57 rows=1 width=56) (actual time=0.001..0.018 rows=37 loops=590381) + -> Gather (cost=85492.68..680956.56 rows=1 width=56) (actual time=839.686..9884.758 rows=37 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=84492.68..679956.46 rows=1 width=56) (actual time=556.207..9867.446 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.85..597426.49 rows=89085 width=24) (actual time=2.651..9359.725 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..571766.37 rows=6001437 width=32) (actual time=0.160..8997.390 rows=4800420 loops=3) + -> Parallel Hash (cost=2622.84..2622.84 rows=641 width=8) (actual time=2.456..2.456 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=641 width=8) (actual time=1.225..2.387 rows=365 loops=3) + Filter: (d_year = ANY ('{1999,2000,2001}'::bigint[])) + Rows Removed by Filter: 23984 + -> Parallel Hash (cost=81833.32..81833.32 rows=1901 width=32) (actual time=260.923..260.927 rows=61011 loops=3) + Buckets: 262144 (originally 8192) Batches: 1 (originally 1) Memory Usage: 15296kB + -> Parallel Hash Join (cost=2784.86..81833.32 rows=1901 width=32) (actual time=86.144..202.362 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.24 rows=1198924 width=40) (actual time=0.023..67.247 rows=959177 loops=3) + -> Parallel Hash (cost=2783.97..2783.97 rows=71 width=8) (actual time=1.468..1.469 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=71 width=8) (actual time=2.298..4.384 rows=122 loops=1) + Filter: ((d_moy <= 15) AND (d_moy >= 9) AND (d_year = 1999)) + Rows Removed by Filter: 72927 +Planning Time: 3.228 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 6.007 ms, Inlining 134.766 ms, Optimization 377.055 ms, Emission 250.728 ms, Total 768.555 ms +Execution Time: 25208.161 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.6819585639996149,2.4294510019999507,"Limit (cost=57194.20..57194.34 rows=54 width=134) (actual time=281.847..284.077 rows=100 loops=1) + -> Sort (cost=57194.20..57194.34 rows=54 width=134) (actual time=281.846..284.071 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=57081.81..57192.65 rows=54 width=134) (actual time=237.561..283.321 rows=1617 loops=1) + Hash Cond: (cwa.ctr_customer_sk = c.c_customer_sk) + -> Subquery Scan on cwa (cost=32663.35..32769.56 rows=1089 width=40) (actual time=190.178..231.556 rows=33338 loops=1) + Filter: (cwa.ctr_total_return > (cwa.state_avg_return * 1.2)) + Rows Removed by Filter: 98417 + -> WindowAgg (cost=32663.35..32720.54 rows=3268 width=75) (actual time=190.171..219.428 rows=131755 loops=1) + -> Sort (cost=32663.35..32671.52 rows=3268 width=43) (actual time=190.013..198.706 rows=131755 loops=1) + Sort Key: ctr.ctr_state + Sort Method: external merge Disk: 4216kB + -> Subquery Scan on ctr (cost=32059.44..32472.60 rows=3268 width=43) (actual time=85.230..165.017 rows=131755 loops=1) + -> Finalize GroupAggregate (cost=32059.44..32472.60 rows=3268 width=43) (actual time=85.229..158.048 rows=131755 loops=1) + Group Key: wr.wr_returning_customer_sk, ca_1.ca_state + -> Gather Merge (cost=32059.44..32404.51 rows=2724 width=43) (actual time=85.220..114.753 rows=132224 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=31059.42..31090.07 rows=1362 width=43) (actual time=75.281..91.851 rows=44075 loops=3) + Group Key: wr.wr_returning_customer_sk, ca_1.ca_state + -> Sort (cost=31059.42..31062.83 rows=1362 width=17) (actual time=75.267..77.802 rows=44708 loops=3) + Sort Key: wr.wr_returning_customer_sk, ca_1.ca_state + Sort Method: quicksort Memory: 3326kB + Worker 0: Sort Method: quicksort Memory: 3789kB + Worker 1: Sort Method: quicksort Memory: 3209kB + -> Parallel Hash Join (cost=25062.56..30988.52 rows=1362 width=17) (actual time=50.604..67.785 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.010..5.805 rows=83333 loops=3) + -> Parallel Hash (cost=25044.74..25044.74 rows=1425 width=22) (actual time=50.456..50.459 rows=45790 loops=3) + Buckets: 262144 (originally 4096) Batches: 1 (originally 1) Memory Usage: 11456kB + -> Parallel Hash Join (cost=2571.80..25044.74 rows=1425 width=22) (actual time=2.901..39.495 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.011..18.761 rows=239741 loops=3) + -> Parallel Hash (cost=2569.12..2569.12 rows=214 width=8) (actual time=2.879..2.879 rows=122 loops=3) + Buckets: 1024 Batches: 1 Memory Usage: 40kB + -> Parallel Seq Scan on date_dim d (cost=0.00..2569.12 rows=214 width=8) (actual time=4.233..8.598 rows=365 loops=1) + Filter: (d_year = 2002) + Rows Removed by Filter: 72684 + -> Hash (cost=24109.09..24109.09 rows=24750 width=110) (actual time=47.360..47.561 rows=24415 loops=1) + Buckets: 32768 Batches: 1 Memory Usage: 3803kB + -> Gather (cost=6854.53..24109.09 rows=24750 width=110) (actual time=17.127..43.644 rows=24415 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Parallel Hash Join (cost=5854.53..20634.09 rows=10312 width=110) (actual time=9.227..36.362 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.009..13.435 rows=166667 loops=3) + -> Parallel Hash (cost=5790.08..5790.08 rows=5156 width=8) (actual time=9.010..9.010 rows=4029 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 672kB + -> Parallel Seq Scan on customer_address ca (cost=0.00..5790.08 rows=5156 width=8) (actual time=0.017..8.516 rows=4029 loops=3) + Filter: ((ca_state)::text = 'GA'::text) + Rows Removed by Filter: 79304 +Planning Time: 0.266 ms +Execution Time: 284.607 ms","Limit (cost=466272571.83..467873803.32 rows=24 width=134) (actual time=2350.216..4258.542 rows=100 loops=1) + CTE _s0 + -> Seq Scan on web_returns (cost=0.00..25536.22 rows=719222 width=30) (actual time=0.008..58.815 rows=719222 loops=1) + CTE _t5 + -> Seq Scan on date_dim (cost=0.00..2945.11 rows=363 width=16) (actual time=1.530..3.018 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.016..19.810 rows=250000 loops=1) + -> Incremental Sort (cost=466237102.49..467838333.99 rows=24 width=134) (actual time=1997.120..3905.438 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=466167483.77..467838332.91 rows=24 width=134) (actual time=1043.053..3905.355 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=233094902.64..234748131.28 rows=220 width=182) (actual time=720.394..3393.187 rows=101 loops=1) + Join Filter: (_t1.wr_returning_customer_sk = customer.c_customer_sk) + Rows Removed by Join Filter: 51184096 + -> Gather Merge (cost=22321.51..25204.05 rows=24750 width=110) (actual time=218.801..225.247 rows=1533 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=21321.49..21347.27 rows=10312 width=110) (actual time=207.714..207.815 rows=775 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: 1189kB + Worker 0: Sort Method: quicksort Memory: 1203kB + Worker 1: Sort Method: quicksort Memory: 1733kB + -> Parallel Hash Join (cost=5854.53..20634.09 rows=10312 width=110) (actual time=164.719..191.090 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.024..13.393 rows=166667 loops=3) + -> Parallel Hash (cost=5790.08..5790.08 rows=5156 width=8) (actual time=164.535..164.536 rows=4029 loops=3) + Buckets: 16384 Batches: 1 Memory Usage: 672kB + -> Parallel Seq Scan on customer_address (cost=0.00..5790.08 rows=5156 width=8) (actual time=106.507..114.441 rows=4029 loops=3) + Filter: ((ca_state)::text = 'GA'::text) + Rows Removed by Filter: 79304 + -> Materialize (cost=233072581.13..233073103.34 rows=4444 width=72) (actual time=0.287..1.197 rows=33388 loops=1533) + -> Subquery Scan on _t1 (cost=233072581.13..233073081.12 rows=4444 width=72) (actual time=440.537..490.738 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=233072581.13..233072847.79 rows=13333 width=80) (actual time=440.531..477.588 rows=131787 loops=1) + -> Sort (cost=233072581.13..233072614.46 rows=13333 width=72) (actual time=440.302..447.784 rows=131787 loops=1) + Sort Key: _t3.returning_state + Sort Method: external merge Disk: 4344kB + -> Subquery Scan on _t3 (cost=201201110.09..233071667.64 rows=13333 width=72) (actual time=357.061..415.737 rows=131787 loops=1) + -> HashAggregate (cost=201201110.09..233071534.31 rows=13333 width=80) (actual time=357.059..409.255 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=289224.74..24769763.21 rows=1631735000 width=54) (actual time=280.874..328.843 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=65.215..76.214 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.020..46.641 rows=250000 loops=1) + -> Materialize (cost=256682.78..263209.72 rows=1305388 width=30) (actual time=215.612..231.319 rows=137371 loops=1) + -> Sort (cost=256682.78..259946.25 rows=1305388 width=30) (actual time=215.611..223.116 rows=137371 loops=1) + Sort Key: _s0.wr_returning_addr_sk + Sort Method: external merge Disk: 4512kB + -> Hash Join (cost=11.80..61613.16 rows=1305388 width=30) (actual time=3.103..195.478 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.009..152.084 rows=719222 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=3.076..3.077 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 (cost=0.00..7.26 rows=363 width=8) (actual time=1.532..3.055 rows=365 loops=1) + -> Materialize (cost=233072581.13..233073103.34 rows=4444 width=40) (actual time=2.729..4.078 rows=33349 loops=101) + -> Subquery Scan on _t6 (cost=233072581.13..233073081.12 rows=4444 width=40) (actual time=275.643..325.550 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=233072581.13..233072847.79 rows=13333 width=80) (actual time=275.638..312.391 rows=131787 loops=1) + -> Sort (cost=233072581.13..233072614.46 rows=13333 width=72) (actual time=275.323..282.882 rows=131787 loops=1) + Sort Key: _t8.returning_state + Sort Method: external merge Disk: 4344kB + -> Subquery Scan on _t8 (cost=201201110.09..233071667.64 rows=13333 width=72) (actual time=191.589..250.756 rows=131787 loops=1) + -> HashAggregate (cost=201201110.09..233071534.31 rows=13333 width=80) (actual time=191.586..244.277 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=289224.74..24769763.21 rows=1631735000 width=54) (actual time=116.814..164.825 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=29.942..40.889 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.012..11.593 rows=250000 loops=1) + -> Materialize (cost=256682.78..263209.72 rows=1305388 width=30) (actual time=86.860..102.375 rows=137371 loops=1) + -> Sort (cost=256682.78..259946.25 rows=1305388 width=30) (actual time=86.859..94.234 rows=137371 loops=1) + Sort Key: _s4.wr_returning_addr_sk + Sort Method: external merge Disk: 4512kB + -> Hash Join (cost=11.80..61613.16 rows=1305388 width=30) (actual time=0.061..68.025 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.009..31.056 rows=719222 loops=1) + -> Hash (cost=7.26..7.26 rows=363 width=8) (actual time=0.039..0.040 rows=365 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 23kB + -> CTE Scan on _t5 _t10 (cost=0.00..7.26 rows=363 width=8) (actual time=0.002..0.017 rows=365 loops=1) +Planning Time: 0.380 ms +JIT: + Functions: 138 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.956 ms, Inlining 86.303 ms, Optimization 379.282 ms, Emission 258.003 ms, Total 728.544 ms +Execution Time: 4270.369 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",26.899763993000306,21.275582393999684,"Limit (cost=4374599.82..4374599.82 rows=1 width=214) (actual time=24882.027..24889.176 rows=100 loops=1) + CTE ss + -> Finalize GroupAggregate (cost=2463856.29..2863847.02 rows=1476800 width=62) (actual time=13697.051..13746.480 rows=38504 loops=1) + Group Key: ca.ca_county, d.d_qoy, d.d_year + -> Gather Merge (cost=2463856.29..2808467.02 rows=2953600 width=62) (actual time=13697.011..13719.701 rows=113566 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Sort (cost=2462856.27..2466548.27 rows=1476800 width=62) (actual time=13628.347..13632.551 rows=37855 loops=3) + Sort Key: ca.ca_county, d.d_qoy, d.d_year + Sort Method: external merge Disk: 4112kB + Worker 0: Sort Method: external merge Disk: 4112kB + Worker 1: Sort Method: external merge Disk: 4120kB + -> Partial HashAggregate (cost=2012172.99..2200473.26 rows=1476800 width=62) (actual time=13249.276..13592.814 rows=37855 loops=3) + Group Key: ca.ca_county, d.d_qoy, d.d_year + Planned Partitions: 64 Batches: 65 Memory Usage: 8209kB Disk Usage: 191592kB + Worker 0: Batches: 65 Memory Usage: 8209kB Disk Usage: 191680kB + Worker 1: Batches: 65 Memory Usage: 8209kB Disk Usage: 197640kB + -> Parallel Hash Join (cost=9830.58..1006718.62 rows=10869777 width=36) (actual time=164.709..11643.140 rows=8951984 loops=3) + Hash Cond: (ss.ss_sold_date_sk = d.d_date_sk) + -> Parallel Hash Join (cost=6831.75..896946.56 rows=11422232 width=28) (actual time=159.878..10698.184 rows=9168133 loops=3) + Hash Cond: (ss.ss_addr_sk = ca.ca_address_sk) + -> Parallel Seq Scan on store_sales ss (cost=0.00..797525.83 rows=11998983 width=22) (actual time=0.009..9056.224 rows=9600330 loops=3) + -> Parallel Hash (cost=5529.67..5529.67 rows=104167 width=22) (actual time=159.662..159.663 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=104.788..111.217 rows=83333 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=4.414..4.415 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.019..5.603 rows=73049 loops=1) + CTE ws + -> Finalize GroupAggregate (cost=836959.65..1289194.58 rows=1476800 width=62) (actual time=2595.321..3354.639 rows=37641 loops=1) + Group Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + -> Gather Merge (cost=836959.65..1233814.58 rows=2953600 width=62) (actual time=2595.308..3328.984 rows=102973 loops=1) + Workers Planned: 2 + Workers Launched: 2 + -> Partial GroupAggregate (cost=835959.63..891895.83 rows=1476800 width=62) (actual time=2569.517..3146.905 rows=34324 loops=3) + Group Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + -> Sort (cost=835959.63..843454.87 rows=2998096 width=36) (actual time=2569.466..2922.906 rows=2398318 loops=3) + Sort Key: ca_1.ca_county, d_1.d_qoy, d_1.d_year + Sort Method: external merge Disk: 100104kB + Worker 0: Sort Method: external merge Disk: 152232kB + Worker 1: Sort Method: external merge Disk: 99720kB + -> Parallel Hash Join (cost=9830.58..349469.23 rows=2998096 width=36) (actual time=186.528..1002.665 rows=2398318 loops=3) + Hash Cond: (ws.ws_sold_date_sk = d_1.d_date_sk) + -> Parallel Hash Join (cost=6831.75..317590.56 rows=2998396 width=28) (actual time=21.524..605.853 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..287019.96 rows=2998796 width=22) (actual time=0.209..231.047 rows=2399189 loops=3) + -> Parallel Hash (cost=5529.67..5529.67 rows=104167 width=22) (actual time=21.106..21.107 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=0.042..8.180 rows=83333 loops=3) + -> Parallel Hash (cost=2461.70..2461.70 rows=42970 width=24) (actual time=164.604..164.605 rows=24350 loops=3) + Buckets: 131072 Batches: 1 Memory Usage: 5088kB + -> Parallel Seq Scan on date_dim d_1 (cost=0.00..2461.70 rows=42970 width=24) (actual time=105.930..108.264 rows=24350 loops=3) + -> Sort (cost=221558.22..221558.23 rows=1 width=214) (actual time=24487.022..24487.032 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=17164.490..24486.839 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=17119.949..23661.860 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=16292.440..21272.247 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=13697.089..17104.829 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=13697.076..15371.818 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=13697.061..13698.044 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.000..0.850 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.000..0.884 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=1.406..2.205 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.000..1.241 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.000..0.830 rows=1847 loops=930) + Filter: ((d_year = 2000) AND (d_qoy = 3)) + Rows Removed by Filter: 35794 +Planning Time: 0.846 ms +JIT: + Functions: 191 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 7.760 ms, Inlining 187.465 ms, Optimization 539.521 ms, Emission 379.618 ms, Total 1114.365 ms +Execution Time: 24926.527 ms","Limit (cost=455494819644.86..455494819644.92 rows=22 width=68) (actual time=24391.969..24391.998 rows=100 loops=1) + CTE _s4 + -> Seq Scan on customer_address (cost=0.00..6988.00 rows=250000 width=22) (actual time=0.040..19.154 rows=250000 loops=1) + CTE _s0 + -> Seq Scan on store_sales (cost=0.00..965511.60 rows=28797560 width=22) (actual time=0.008..8340.058 rows=28800991 loops=1) + CTE _t10 + -> Seq Scan on date_dim (cost=0.00..3127.73 rows=90 width=24) (actual time=1.823..3.625 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=92 width=24) (actual time=1.757..3.425 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=91 width=24) (actual time=1.893..3.827 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..329003.10 rows=7197110 width=22) (actual time=0.375..731.329 rows=7197566 loops=1) + -> Sort (cost=455493508758.96..455493508759.01 rows=22 width=68) (actual time=23688.181..23688.201 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=455493508739.36..455493508758.46 rows=22 width=68) (actual time=23648.264..23688.135 rows=307 loops=1) + -> GroupAggregate (cost=455493508739.36..455493508757.36 rows=22 width=224) (actual time=23648.259..23687.947 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=455493508739.36..455493508739.86 rows=200 width=224) (actual time=23647.868..23663.231 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=11004815.31..455493508731.72 rows=200 width=224) (actual time=21320.006..23533.829 rows=250000 loops=1) + -> GroupAggregate (cost=11004815.31..455493508729.72 rows=200 width=232) (actual time=21320.004..23517.541 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=11004815.31..455412050936.60 rows=4072889531 width=214) (actual time=21319.975..23395.823 rows=594015 loops=1) + Merge Cond: (_s4.ca_address_sk = _s30.ws_bill_addr_sk) + -> GroupAggregate (cost=10281753.94..455289131757.27 rows=200 width=200) (actual time=20672.472..22579.734 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=10281753.94..455217072939.99 rows=4117646559 width=182) (actual time=20672.432..22484.567 rows=436544 loops=1) + Merge Cond: (_s4.ca_address_sk = _s24.ws_bill_addr_sk) + -> GroupAggregate (cost=9552700.46..455092804961.36 rows=200 width=168) (actual time=20057.822..21760.448 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=9552700.46..455032382971.31 rows=4028132503 width=150) (actual time=20057.775..21674.415 rows=444366 loops=1) + Merge Cond: (_s4.ca_address_sk = _s18.ws_bill_addr_sk) + -> GroupAggregate (cost=8835628.23..454910812573.65 rows=200 width=136) (actual time=18113.908..19620.909 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=8835628.23..454707103581.29 rows=16296719189 width=118) (actual time=18113.859..19450.600 rows=1540400 loops=1) + Merge Cond: (_s4.ca_address_sk = _s12.ss_addr_sk) + -> GroupAggregate (cost=5903550.78..454215235922.96 rows=200 width=104) (actual time=15584.466..16420.662 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=5903550.78..454050477880.31 rows=16475804015 width=86) (actual time=15584.447..16313.131 rows=940049 loops=1) + Merge Cond: (_s4.ca_address_sk = _s6.ss_addr_sk) + -> GroupAggregate (cost=2946059.26..453553211899.44 rows=200 width=72) (actual time=13196.829..13625.805 rows=250000 loops=1) + Group Key: _s4.ca_address_sk + -> Merge Left Join (cost=2946059.26..302450389753.19 rows=20147042952500 width=100) (actual time=13196.801..13523.586 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=67.229..81.977 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.044..51.257 rows=250000 loops=1) + -> Materialize (cost=2906681.80..284998924.14 rows=16117634362 width=22) (actual time=13129.552..13369.469 rows=793573 loops=1) + -> Merge Join (cost=2906681.80..244704838.23 rows=16117634362 width=22) (actual time=13129.550..13302.051 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=25.003..34.911 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.013..12.044 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2875986.40..2940780.91 rows=12958902 width=22) (actual time=13104.503..13203.075 rows=819009 loops=1) + -> Sort (cost=2875986.40..2908383.66 rows=12958902 width=22) (actual time=13104.501..13154.984 rows=819009 loops=1) + Sort Key: _s0.ss_addr_sk + Sort Method: external merge Disk: 21176kB + -> Hash Join (cost=2.92..813534.00 rows=12958902 width=22) (actual time=3.677..13015.950 rows=838762 loops=1) + Hash Cond: (_s0.ss_sold_date_sk = _t10.d_date_sk) + -> CTE Scan on _s0 (cost=0.00..575951.20 rows=28797560 width=30) (actual time=0.009..11786.079 rows=28800991 loops=1) + -> Hash (cost=1.80..1.80 rows=90 width=8) (actual time=3.649..3.650 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t10 (cost=0.00..1.80 rows=90 width=8) (actual time=1.825..3.636 rows=91 loops=1) + -> Materialize (cost=2957491.52..291318430.18 rows=16475804015 width=22) (actual time=2387.610..2618.778 rows=748583 loops=1) + -> Merge Join (cost=2957491.52..250128920.14 rows=16475804015 width=22) (actual time=2387.609..2554.296 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=25.312..35.184 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.009..12.420 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2926796.13..2993030.52 rows=13246878 width=22) (actual time=2362.263..2456.512 rows=772346 loops=1) + -> Sort (cost=2926796.13..2959913.32 rows=13246878 width=22) (actual time=2362.261..2411.135 rows=772346 loops=1) + Sort Key: _s6.ss_addr_sk + Sort Method: external merge Disk: 19968kB + -> Hash Join (cost=2.99..816413.82 rows=13246878 width=22) (actual time=3.498..2286.056 rows=791057 loops=1) + Hash Cond: (_s6.ss_sold_date_sk = _t12.d_date_sk) + -> CTE Scan on _s0 _s6 (cost=0.00..575951.20 rows=28797560 width=30) (actual time=0.012..1193.260 rows=28800991 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=3.446..3.447 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t12 (cost=0.00..1.84 rows=92 width=8) (actual time=1.759..3.436 rows=91 loops=1) + -> Materialize (cost=2932077.45..288158667.97 rows=16296719189 width=22) (actual time=2529.386..2921.145 rows=1387452 loops=1) + -> Merge Join (cost=2932077.45..247416870.00 rows=16296719189 width=22) (actual time=2529.384..2803.725 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=26.096..36.321 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.008..12.322 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=2901382.06..2966896.51 rows=13102890 width=22) (actual time=2503.240..2665.131 rows=1431272 loops=1) + -> Sort (cost=2901382.06..2934139.28 rows=13102890 width=22) (actual time=2503.238..2581.065 rows=1431272 loops=1) + Sort Key: _s12.ss_addr_sk + Sort Method: external merge Disk: 36944kB + -> Hash Join (cost=2.96..814973.91 rows=13102890 width=22) (actual time=3.876..2310.021 rows=1465854 loops=1) + Hash Cond: (_s12.ss_sold_date_sk = _t14.d_date_sk) + -> CTE Scan on _s0 _s12 (cost=0.00..575951.20 rows=28797560 width=30) (actual time=0.002..1198.463 rows=28800991 loops=1) + -> Hash (cost=1.82..1.82 rows=91 width=8) (actual time=3.849..3.849 rows=92 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t14 (cost=0.00..1.82 rows=91 width=8) (actual time=1.896..3.840 rows=92 loops=1) + -> Materialize (cost=717072.24..71218740.87 rows=4028132503 width=22) (actual time=1943.860..2020.315 rows=211467 loops=1) + -> Merge Join (cost=717072.24..61148409.61 rows=4028132503 width=22) (actual time=1943.858..2001.908 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=27.345..36.474 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.007..12.184 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=686376.84..702570.34 rows=3238700 width=22) (actual time=1916.457..1943.254 rows=218521 loops=1) + -> Sort (cost=686376.84..694473.59 rows=3238700 width=22) (actual time=1916.455..1930.453 rows=218521 loops=1) + Sort Key: _s18.ws_bill_addr_sk + Sort Method: external merge Disk: 5632kB + -> Hash Join (cost=2.92..203321.29 rows=3238700 width=22) (actual time=0.683..1891.615 rows=218549 loops=1) + Hash Cond: (_s18.ws_sold_date_sk = _t16.d_date_sk) + -> CTE Scan on _s18 (cost=0.00..143942.20 rows=7197110 width=30) (actual time=0.377..1579.932 rows=7197566 loops=1) + -> Hash (cost=1.80..1.80 rows=90 width=8) (actual time=0.016..0.016 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t10 _t16 (cost=0.00..1.80 rows=90 width=8) (actual time=0.003..0.007 rows=91 loops=1) + -> Materialize (cost=729053.48..72797396.14 rows=4117646559 width=22) (actual time=614.603..690.538 rows=202862 loops=1) + -> Merge Join (cost=729053.48..62503279.75 rows=4117646559 width=22) (actual time=614.602..672.287 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=26.729..35.799 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.007..12.411 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=698358.08..714911.44 rows=3310671 width=22) (actual time=587.852..613.063 rows=208375 loops=1) + -> Sort (cost=698358.08..706634.76 rows=3310671 width=22) (actual time=587.851..600.822 rows=208375 loops=1) + Sort Key: _s24.ws_bill_addr_sk + Sort Method: external merge Disk: 5368kB + -> Hash Join (cost=2.99..204041.06 rows=3310671 width=22) (actual time=0.079..566.733 rows=208401 loops=1) + Hash Cond: (_s24.ws_sold_date_sk = _t18.d_date_sk) + -> CTE Scan on _s18 _s24 (cost=0.00..143942.20 rows=7197110 width=30) (actual time=0.012..296.236 rows=7197566 loops=1) + -> Hash (cost=1.84..1.84 rows=92 width=8) (actual time=0.016..0.017 rows=91 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t12 _t18 (cost=0.00..1.84 rows=92 width=8) (actual time=0.002..0.007 rows=91 loops=1) + -> Materialize (cost=723061.37..72008057.69 rows=4072889531 width=22) (actual time=647.495..769.565 rows=373250 loops=1) + -> Merge Join (cost=723061.37..61825833.87 rows=4072889531 width=22) (actual time=647.493..737.458 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=26.383..35.794 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.006..12.380 rows=242498 loops=1) + Filter: (ca_county IS NOT NULL) + Rows Removed by Filter: 7502 + -> Materialize (cost=692365.97..708739.40 rows=3274685 width=22) (actual time=621.090..667.668 rows=384796 loops=1) + -> Sort (cost=692365.97..700552.69 rows=3274685 width=22) (actual time=621.089..645.193 rows=384796 loops=1) + Sort Key: _s30.ws_bill_addr_sk + Sort Method: external merge Disk: 9912kB + -> Hash Join (cost=2.96..203681.17 rows=3274685 width=22) (actual time=0.036..583.400 rows=384834 loops=1) + Hash Cond: (_s30.ws_sold_date_sk = _t20.d_date_sk) + -> CTE Scan on _s18 _s30 (cost=0.00..143942.20 rows=7197110 width=30) (actual time=0.002..301.035 rows=7197566 loops=1) + -> Hash (cost=1.82..1.82 rows=91 width=8) (actual time=0.016..0.016 rows=92 loops=1) + Buckets: 1024 Batches: 1 Memory Usage: 12kB + -> CTE Scan on _t14 _t20 (cost=0.00..1.82 rows=91 width=8) (actual time=0.004..0.008 rows=92 loops=1) +Planning Time: 0.780 ms +JIT: + Functions: 197 + Options: Inlining true, Optimization true, Expressions true, Deforming true + Timing: Generation 4.849 ms, Inlining 9.508 ms, Optimization 394.678 ms, Emission 299.932 ms, Total 708.966 ms +Execution Time: 24546.477 ms",SUCCESS