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 = 'EUROPE' and o_orderdate >= date '1993-01-01' and o_orderdate < date '1993-01-01' + interval '1 year' group by n_name order by revenue desc; QUERY PLAN ---------------------------------------------------------------------------------------------------------------------------------------------------------------- Sort (cost=2856553.34..2856553.40 rows=25 width=34) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))) -> HashAggregate (cost=2856552.51..2856552.76 rows=25 width=34) Group Key: nation.n_name -> Hash Join (cost=453450.77..2855850.59 rows=70192 width=34) Hash Cond: ((orders.o_custkey = customer.c_custkey) AND (supplier.s_nationkey = customer.c_nationkey)) -> Hash Join (cost=374803.85..2704706.38 rows=1754568 width=46) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Hash Join (cost=4007.53..2012079.24 rows=11785619 width=46) Hash Cond: (lineitem.l_suppkey = supplier.s_suppkey) -> Seq Scan on lineitem (cost=0.00..1665268.56 rows=59985856 width=16) -> Hash (cost=3757.53..3757.53 rows=20000 width=38) -> Hash Join (cost=2.53..3757.53 rows=20000 width=38) Hash Cond: (supplier.s_nationkey = nation.n_nationkey) -> Seq Scan on supplier (cost=0.00..3180.00 rows=100000 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 = 'EUROPE'::bpchar) -> Hash (cost=334159.78..334159.78 rows=2233083 width=8) -> Bitmap Heap Scan on orders (cost=47385.54..334159.78 rows=2233083 width=8) Recheck Cond: ((o_orderdate >= '1993-01-01'::date) AND (o_orderdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Bitmap Index Scan on i_o_orderdate (cost=0.00..46827.26 rows=2233083 width=0) Index Cond: ((o_orderdate >= '1993-01-01'::date) AND (o_orderdate < '1994-01-01 00:00:00'::timestamp without time zone)) -> Hash (cost=50285.17..50285.17 rows=1500117 width=8) -> Seq Scan on customer (cost=0.00..50285.17 rows=1500117 width=8) (29 rows)