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-09' and l_shipdate > date '1995-03-09' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2669855.79..2669855.81 rows=10 width=20) (actual time=38048.336..38048.342 rows=10 loops=1) Buffers: shared hit=754900 read=602858 written=2726 -> Sort (cost=2669855.79..2677703.12 rows=3138934 width=20) (actual time=38048.332..38048.334 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=754900 read=602858 written=2726 -> HashAggregate (cost=2570635.21..2602024.55 rows=3138934 width=20) (actual time=37962.907..38026.850 rows=114070 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=754894 read=602858 written=2726 -> Hash Join (cost=551093.63..2523551.20 rows=3138934 width=20) (actual time=11722.581..37700.385 rows=302214 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=754894 read=602858 written=2726 -> Seq Scan on lineitem (cost=0.00..1818868.36 rows=32586633 width=12) (actual time=0.061..19408.595 rows=32483938 loops=1) Filter: (l_shipdate > '1995-03-09'::date) Rows Removed by Filter: 27501614 Buffers: shared hit=594906 read=472640 written=1 -> Hash (cost=532996.45..532996.45 rows=1447774 width=12) (actual time=11703.135..11703.135 rows=1454302 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78874kB Buffers: shared hit=159988 read=130218 written=2725 -> Hash Join (cost=49736.01..532996.45 rows=1447774 width=12) (actual time=1107.358..10941.520 rows=1454302 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=159988 read=130218 written=2725 -> Seq Scan on orders (cost=0.00..441649.60 rows=7235493 width=16) (actual time=0.038..5786.092 rows=7252181 loops=1) Filter: (o_orderdate < '1995-03-09'::date) Rows Removed by Filter: 7747819 Buffers: shared hit=159985 read=93790 written=2725 -> Hash (cost=45984.26..45984.26 rows=300140 width=4) (actual time=1103.399..1103.399 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=3 read=36428 -> Bitmap Heap Scan on customer (cost=6954.51..45984.26 rows=300140 width=4) (actual time=126.624..950.068 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=3 read=36428 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.48 rows=300140 width=0) (actual time=109.642..109.642 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 5.855 ms Execution time: 38084.209 ms (38 rows) COMMIT; COMMIT