BEGIN; BEGIN EXPLAIN select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-16' and l_shipdate > date '1995-03-16' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2763253.98..2763254.00 rows=10 width=48) -> Sort (cost=2763253.98..2770993.93 rows=3095981 width=48) Sort Key: (sum((lineitem.l_extendedprice * ('1'::numeric - lineitem.l_discount)))) DESC, orders.o_orderdate -> Finalize GroupAggregate (cost=2288907.45..2696350.94 rows=3095981 width=48) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority -> Gather Merge (cost=2288907.45..2625401.38 rows=2579984 width=48) Workers Planned: 2 -> Partial GroupAggregate (cost=2287907.42..2326607.18 rows=1289992 width=48) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority -> Sort (cost=2287907.42..2291132.40 rows=1289992 width=28) Sort Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority -> Parallel Hash Join (cost=410956.03..2095247.13 rows=1289992 width=28) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Parallel Seq Scan on lineitem (cost=0.00..1468753.24 rows=13395969 width=20) Filter: (l_shipdate > '1995-03-16'::date) -> Parallel Hash (cost=400484.05..400484.05 rows=602399 width=16) -> Parallel Hash Join (cost=9570.25..400484.05 rows=602399 width=16) Hash Cond: (orders.o_custkey = customer.c_custkey) -> Parallel Seq Scan on orders (cost=0.00..346518.38 rows=3061484 width=20) Filter: (o_orderdate < '1995-03-16'::date) -> Parallel Hash (cost=7551.96..7551.96 rows=122983 width=4) -> Parallel Index Only Scan using customer_c_mktsegment_c_custkey_idx on customer (cost=0.43..7551.96 rows=122983 width=4) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) (23 rows) COMMIT; COMMIT