load 'auto_explain'; LOAD set auto_explain.log_min_duration to 0; SET set auto_explain.log_analyze to on; SET set auto_explain.log_wal to on; SET set auto_explain.log_timing to on; SET set auto_explain.log_level to notice; SET BEGIN; BEGIN select o_year, sum(case when nation = 'IRAQ' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'MIDDLE EAST' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date '1996-12-31' and p_type = 'ECONOMY BURNISHED BRASS' ) as all_nations group by o_year order by o_year; NOTICE: duration: 2363.657 ms plan: Query Text: select o_year, sum(case when nation = 'IRAQ' then volume else 0 end) / sum(volume) as mkt_share from ( select extract(year from o_orderdate) as o_year, l_extendedprice * (1 - l_discount) as volume, n2.n_name as nation from part, supplier, lineitem, orders, customer, nation n1, nation n2, region where p_partkey = l_partkey and s_suppkey = l_suppkey and l_orderkey = o_orderkey and o_custkey = c_custkey and c_nationkey = n1.n_nationkey and n1.n_regionkey = r_regionkey and r_name = 'MIDDLE EAST' and s_nationkey = n2.n_nationkey and o_orderdate between date '1995-01-01' and date '1996-12-31' and p_type = 'ECONOMY BURNISHED BRASS' ) as all_nations group by o_year order by o_year; Finalize GroupAggregate (cost=1258175.65..1259107.10 rows=2406 width=64) (actual time=2320.506..2363.647 rows=2 loops=1) Group Key: (EXTRACT(year FROM orders.o_orderdate)) -> Gather Merge (cost=1258175.65..1258998.83 rows=4812 width=96) (actual time=2317.891..2363.627 rows=6 loops=1) Workers Planned: 2 Workers Launched: 2 -> Partial GroupAggregate (cost=1257175.62..1257443.38 rows=2406 width=96) (actual time=2313.979..2316.607 rows=2 loops=3) Group Key: (EXTRACT(year FROM orders.o_orderdate)) -> Sort (cost=1257175.62..1257200.70 rows=10029 width=70) (actual time=2311.343..2311.781 rows=8251 loops=3) Sort Key: (EXTRACT(year FROM orders.o_orderdate)) Sort Method: quicksort Memory: 1030kB Worker 0: Sort Method: quicksort Memory: 1032kB Worker 1: Sort Method: quicksort Memory: 1025kB -> Hash Join (cost=1254342.54..1256509.10 rows=10029 width=70) (actual time=2295.086..2308.507 rows=8251 loops=3) Hash Cond: (supplier.s_nationkey = n2.n_nationkey) -> Parallel Hash Join (cost=1254340.97..1256451.68 rows=10029 width=20) (actual time=2295.030..2305.481 rows=8251 loops=3) Hash Cond: (supplier.s_suppkey = lineitem.l_suppkey) -> Parallel Index Only Scan using supplier_s_nationkey_s_suppkey_idx on supplier (cost=0.29..1912.96 rows=41667 width=8) (actual time=0.079..4.383 rows=33333 loops=3) Heap Fetches: 0 -> Parallel Hash (cost=1254215.32..1254215.32 rows=10029 width=20) (actual time=2294.813..2294.819 rows=8251 loops=3) Buckets: 32768 Batches: 1 Memory Usage: 1664kB -> Hash Join (cost=862889.60..1254215.32 rows=10029 width=20) (actual time=1995.958..2291.840 rows=8251 loops=3) Hash Cond: (orders.o_custkey = customer.c_custkey) -> Parallel Hash Join (cost=847540.31..1236817.70 rows=50144 width=24) (actual time=1893.649..2149.714 rows=41027 loops=3) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) -> Parallel Seq Scan on orders (cost=0.00..362157.46 rows=1882656 width=16) (actual time=0.029..932.254 rows=1520654 loops=3) Filter: ((o_orderdate >= '1995-01-01'::date) AND (o_orderdate <= '1996-12-31'::date)) Rows Removed by Filter: 3484346 -> Parallel Hash (cost=843221.00..843221.00 rows=235225 width=24) (actual time=664.149..664.151 rows=135161 loops=3) Buckets: 65536 Batches: 8 Memory Usage: 3616kB -> Nested Loop (cost=0.99..843221.00 rows=235225 width=24) (actual time=0.090..609.015 rows=135161 loops=3) -> Parallel Index Only Scan using part_p_type_p_partkey_idx on part (cost=0.43..458.68 rows=7835 width=4) (actual time=0.043..1.627 rows=4492 loops=3) Index Cond: (p_type = 'ECONOMY BURNISHED BRASS'::text) Heap Fetches: 0 -> Index Scan using lineitem_l_partkey_l_quantity_l_shipmode_idx on lineitem (cost=0.56..107.26 rows=30 width=28) (actual time=0.012..0.130 rows=30 loops=13476) Index Cond: (l_partkey = part.p_partkey) -> Hash (cost=10427.17..10427.17 rows=300010 width=4) (actual time=101.329..101.331 rows=299838 loops=3) Buckets: 131072 Batches: 4 Memory Usage: 3666kB -> Nested Loop (cost=0.56..10427.17 rows=300010 width=4) (actual time=0.083..58.636 rows=299838 loops=3) -> Nested Loop (cost=0.14..13.95 rows=5 width=4) (actual time=0.040..0.066 rows=5 loops=3) Join Filter: (n1.n_regionkey = region.r_regionkey) Rows Removed by Join Filter: 20 -> Index Scan using pk_nation on nation n1 (cost=0.14..12.51 rows=25 width=8) (actual time=0.012..0.023 rows=25 loops=3) -> Materialize (cost=0.00..1.07 rows=1 width=4) (actual time=0.001..0.001 rows=1 loops=75) -> Seq Scan on region (cost=0.00..1.06 rows=1 width=4) (actual time=0.013..0.014 rows=1 loops=3) Filter: (r_name = 'MIDDLE EAST'::bpchar) Rows Removed by Filter: 4 -> Index Only Scan using customer_c_nationkey_c_custkey_idx on customer (cost=0.43..1482.62 rows=60002 width=8) (actual time=0.025..7.002 rows=59968 loops=15) Index Cond: (c_nationkey = n1.n_nationkey) Heap Fetches: 0 -> Hash (cost=1.25..1.25 rows=25 width=30) (actual time=0.024..0.025 rows=25 loops=3) Buckets: 1024 Batches: 1 Memory Usage: 10kB -> Seq Scan on nation n2 (cost=0.00..1.25 rows=25 width=30) (actual time=0.014..0.017 rows=25 loops=3) o_year | mkt_share --------+------------------------ 1995 | 0.04120345110724538387 1996 | 0.04183998615075085196 (2 rows) COMMIT; COMMIT