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 = 'SAUDI ARABIA' 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 = 'LARGE PLATED BRASS' ) as all_nations group by o_year order by o_year; NOTICE: duration: 7403.381 ms plan: Query Text: select o_year, sum(case when nation = 'SAUDI ARABIA' 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 = 'LARGE PLATED BRASS' ) as all_nations group by o_year order by o_year; Finalize GroupAggregate (cost=1259629.83..1260561.96 rows=2406 width=64) (actual time=7309.841..7403.363 rows=2 loops=1) Group Key: (EXTRACT(year FROM orders.o_orderdate)) WAL: records=118 bytes=17760 -> Gather Merge (cost=1259629.83..1260453.69 rows=4812 width=96) (actual time=7298.139..7403.317 rows=6 loops=1) Workers Planned: 2 Workers Launched: 2 WAL: records=118 bytes=17760 -> Partial GroupAggregate (cost=1258629.81..1258898.24 rows=2406 width=96) (actual time=7273.373..7280.620 rows=2 loops=3) Group Key: (EXTRACT(year FROM orders.o_orderdate)) WAL: records=118 bytes=17760 -> Sort (cost=1258629.81..1258654.95 rows=10059 width=70) (actual time=7264.269..7265.098 rows=8106 loops=3) Sort Key: (EXTRACT(year FROM orders.o_orderdate)) Sort Method: quicksort Memory: 829kB WAL: records=118 bytes=17760 Worker 0: Sort Method: quicksort Memory: 728kB Worker 1: Sort Method: quicksort Memory: 1112kB -> Hash Join (cost=1255794.22..1257961.07 rows=10059 width=70) (actual time=7211.677..7249.265 rows=8106 loops=3) Hash Cond: (supplier.s_nationkey = n2.n_nationkey) WAL: records=118 bytes=17760 -> Parallel Hash Join (cost=1255792.66..1257903.49 rows=10059 width=20) (actual time=7211.567..7242.648 rows=8106 loops=3) Hash Cond: (supplier.s_suppkey = lineitem.l_suppkey) WAL: records=118 bytes=17760 -> 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.088..11.506 rows=33333 loops=3) Heap Fetches: 0 -> Parallel Hash (cost=1255666.63..1255666.63 rows=10059 width=20) (actual time=7208.106..7208.213 rows=8106 loops=3) Buckets: 32768 Batches: 1 Memory Usage: 1600kB WAL: records=118 bytes=17760 -> Hash Join (cost=863172.23..1255666.63 rows=10059 width=20) (actual time=6642.619..7202.936 rows=8106 loops=3) Hash Cond: (orders.o_custkey = customer.c_custkey) WAL: records=118 bytes=17760 -> Parallel Hash Join (cost=847821.34..1238264.54 rows=50295 width=24) (actual time=6333.833..6826.368 rows=40361 loops=3) Hash Cond: (orders.o_orderkey = lineitem.l_orderkey) WAL: records=118 bytes=17760 -> Parallel Seq Scan on orders (cost=0.00..363241.27 rows=1888290 width=16) (actual time=0.058..2402.132 rows=1519058 loops=3) Filter: ((o_orderdate >= '1995-01-01'::date) AND (o_orderdate <= '1996-12-31'::date)) Rows Removed by Filter: 3480942 -> Parallel Hash (cost=843489.22..843489.22 rows=235929 width=24) (actual time=3130.641..3130.643 rows=133819 loops=3) Buckets: 65536 Batches: 8 Memory Usage: 3616kB WAL: records=118 bytes=17760 -> Nested Loop (cost=0.99..843489.22 rows=235929 width=24) (actual time=0.189..2982.795 rows=133819 loops=3) WAL: records=118 bytes=17760 -> 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.088..5.896 rows=4468 loops=3) Index Cond: (p_type = 'LARGE PLATED BRASS'::text) Heap Fetches: 0 -> Index Scan using lineitem_l_partkey_l_suppkey_l_shipdate_l_quantity_idx on lineitem (cost=0.56..107.30 rows=30 width=28) (actual time=0.033..0.653 rows=30 loops=13404) Index Cond: (l_partkey = part.p_partkey) WAL: records=118 bytes=17760 -> Hash (cost=10428.76..10428.76 rows=300010 width=4) (actual time=307.479..307.483 rows=299838 loops=3) Buckets: 131072 Batches: 4 Memory Usage: 3666kB -> Nested Loop (cost=0.56..10428.76 rows=300010 width=4) (actual time=0.156..173.299 rows=299838 loops=3) -> Nested Loop (cost=0.14..13.95 rows=5 width=4) (actual time=0.069..0.121 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.018..0.040 rows=25 loops=3) -> Materialize (cost=0.00..1.07 rows=1 width=4) (actual time=0.002..0.002 rows=1 loops=75) -> Seq Scan on region (cost=0.00..1.06 rows=1 width=4) (actual time=0.032..0.033 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.94 rows=60002 width=8) (actual time=0.049..19.987 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.048..0.049 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.027..0.033 rows=25 loops=3) o_year | mkt_share --------+------------------------ 1995 | 0.03886070952113183458 1996 | 0.03881656361121741825 (2 rows) COMMIT; COMMIT