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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-20' and l_shipdate > date '1995-03-20' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2771289.75..2771289.78 rows=10 width=20) (actual time=89098.305..89098.308 rows=10 loops=1) Buffers: shared hit=791167 read=579766 dirtied=253 written=5 -> Sort (cost=2771289.75..2779281.91 rows=3196864 width=20) (actual time=89098.301..89098.303 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=791167 read=579766 dirtied=253 written=5 -> HashAggregate (cost=2670238.03..2702206.67 rows=3196864 width=20) (actual time=89000.954..89073.698 rows=114179 loops=1) Buffers: shared hit=791161 read=579766 dirtied=253 written=5 -> Hash Join (cost=631209.58..2622285.07 rows=3196864 width=20) (actual time=29102.875..88431.553 rows=302048 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=791161 read=579766 dirtied=253 written=5 -> Seq Scan on lineitem (cost=0.00..1836999.93 rows=32561846 width=12) (actual time=0.073..35179.579 rows=32239577 loops=1) Filter: (l_shipdate > '1995-03-20'::date) Rows Removed by Filter: 27805417 Buffers: shared hit=510618 read=567570 written=5 -> Hash (cost=612580.36..612580.36 rows=1490338 width=12) (actual time=29100.490..29100.490 rows=1469524 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63144kB Buffers: shared hit=280543 read=12196 dirtied=253 -> Hash Join (cost=49823.51..612580.36 rows=1490338 width=12) (actual time=1339.742..27818.871 rows=1469524 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=280543 read=12196 dirtied=253 -> Seq Scan on orders (cost=0.00..446056.09 rows=7403446 width=16) (actual time=0.018..8196.179 rows=7328331 loops=1) Filter: (o_orderdate < '1995-03-20'::date) Rows Removed by Filter: 7686669 Buffers: shared hit=251410 read=4897 dirtied=253 -> Hash (cost=46049.07..46049.07 rows=301955 width=4) (actual time=1339.448..1339.448 rows=300276 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10557kB Buffers: shared hit=29133 read=7299 -> Bitmap Heap Scan on customer (cost=6996.63..46049.07 rows=301955 width=4) (actual time=166.562..1167.848 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared hit=29133 read=7299 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6921.14 rows=301955 width=0) (actual time=153.644..153.644 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1155 Total runtime: 89139.663 ms (35 rows) COMMIT; COMMIT