BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select l_orderkey, sum(l_extendedprice * (1 - l_discount)) as revenue, o_orderdate, o_shippriority from customer, orders, lineitem where c_mktsegment = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-21' and l_shipdate > date '1995-03-21' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2766806.03..2766806.06 rows=10 width=20) (actual time=64010.404..64010.409 rows=10 loops=1) Buffers: shared hit=602857 read=766749 dirtied=251 -> Sort (cost=2766806.03..2774727.49 rows=3168581 width=20) (actual time=64010.400..64010.403 rows=10 loops=1) Sort Key: (sum((lineitem.l_extendedprice * (1::double precision - lineitem.l_discount)))), orders.o_orderdate Sort Method: top-N heapsort Memory: 25kB Buffers: shared hit=602857 read=766749 dirtied=251 -> HashAggregate (cost=2666648.33..2698334.14 rows=3168581 width=20) (actual time=63905.615..63989.335 rows=113234 loops=1) Buffers: shared hit=602851 read=766749 dirtied=251 -> Hash Join (cost=630225.78..2619119.61 rows=3168581 width=20) (actual time=22343.275..63554.586 rows=298608 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=602851 read=766749 dirtied=251 -> Seq Scan on lineitem (cost=0.00..1835185.45 rows=32539354 width=12) (actual time=0.120..20557.487 rows=32182396 loops=1) Filter: (l_shipdate > '1995-03-21'::date) Rows Removed by Filter: 27802430 Buffers: shared hit=311821 read=765299 -> Hash (cost=611766.84..611766.84 rows=1476715 width=12) (actual time=22340.093..22340.093 rows=1465938 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62990kB Buffers: shared hit=291030 read=1450 dirtied=251 -> Hash Join (cost=49708.91..611766.84 rows=1476715 width=12) (actual time=567.037..21237.927 rows=1465938 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=291030 read=1450 dirtied=251 -> Seq Scan on orders (cost=0.00..445615.79 rows=7394545 width=16) (actual time=0.026..4968.808 rows=7327294 loops=1) Filter: (o_orderdate < '1995-03-21'::date) Rows Removed by Filter: 7672706 Buffers: shared hit=255755 read=299 dirtied=251 -> Hash (cost=45964.47..45964.47 rows=299555 width=4) (actual time=566.734..566.734 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=35275 read=1151 -> Bitmap Heap Scan on customer (cost=6942.03..45964.47 rows=299555 width=4) (actual time=114.629..474.526 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=35275 read=1151 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.14 rows=299555 width=0) (actual time=102.726..102.726 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 Total runtime: 64056.404 ms (35 rows) COMMIT; COMMIT