BEGIN; BEGIN EXPLAIN select n_name, sum(l_extendedprice * (1 - l_discount)) as revenue from customer, orders, lineitem, supplier, nation, region where c_custkey = o_custkey and l_orderkey = o_orderkey and l_suppkey = s_suppkey and c_nationkey = s_nationkey and s_nationkey = n_nationkey and n_regionkey = r_regionkey and r_name = 'AMERICA' and o_orderdate >= date '1995-01-01' and o_orderdate < date '1995-01-01' + interval '1 year' group by n_name order by revenue desc; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=23202967.20..23202967.26 rows=25 width=34) Sort Key: (sum((sum((lineitem.l_extendedprice * ('1'::double precision - lineitem.l_discount)))))) DESC -> HashAggregate (cost=23202966.37..23202966.62 rows=25 width=34) Group Key: nation.n_name -> Remote Subquery Scan on all (datanode_1_1,datanode_2_1,datanode_3_1,datanode_4_1,datanode_5_1,datanode_6_1,datanode_7_1,datanode_8_1) (cost=4199099.96..23200864.35 rows=210202 width=34) -> HashAggregate (cost=4199099.96..23200864.35 rows=25 width=34) Group Key: nation.n_name -> Hash Join (cost=4199099.96..23200864.35 rows=210202 width=34) Hash Cond: ((lineitem.l_suppkey = supplier.s_suppkey) AND (customer.c_nationkey = supplier.s_nationkey)) -> Hash Join (cost=4152301.96..23112551.44 rows=5255052 width=46) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Seq Scan on lineitem (cost=0.00..16657556.88 rows=600037888 width=16) -> Hash (cost=4135880.96..4135880.96 rows=1313680 width=38) -> Hash Join (cost=1107830.64..4135880.96 rows=1313680 width=38) Hash Cond: (orders.o_custkey = customer.c_custkey) -> Bitmap Heap Scan on orders (cost=481307.11..3354448.12 rows=22683601 width=8) Recheck Cond: ((o_orderdate >= '1995-01-01'::date) AND (o_orderdate < '1996-01-01 00:00:00'::timestamp without time zone)) -> Bitmap Index Scan on orders_o_orderdate_o_orderkey_idx (cost=0.00..475636.21 rows=22683601 width=0) Index Cond: ((o_orderdate >= '1995-01-01'::date) AND (o_orderdate < '1996-01-01 00:00:00'::timestamp without time zone)) -> Hash (cost=589023.53..589023.53 rows=3000000 width=38) -> Hash Join (cost=2.53..589023.53 rows=3000000 width=38) Hash Cond: (customer.c_nationkey = nation.n_nationkey) -> Seq Scan on customer (cost=0.00..502771.00 rows=15000000 width=8) -> Hash (cost=2.47..2.47 rows=5 width=30) -> Hash Join (cost=1.07..2.47 rows=5 width=30) Hash Cond: (nation.n_regionkey = region.r_regionkey) -> Seq Scan on nation (cost=0.00..1.25 rows=25 width=34) -> Hash (cost=1.06..1.06 rows=1 width=4) -> Seq Scan on region (cost=0.00..1.06 rows=1 width=4) Filter: (r_name = 'AMERICA'::bpchar) -> Hash (cost=31798.00..31798.00 rows=1000000 width=8) -> Seq Scan on supplier (cost=0.00..31798.00 rows=1000000 width=8) (32 rows) COMMIT; COMMIT