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-07' and l_shipdate > date '1995-03-07' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2671844.24..2671844.27 rows=10 width=20) (actual time=39986.786..39986.790 rows=10 loops=1) Buffers: shared hit=872662 read=485090 dirtied=774 written=768 -> Sort (cost=2671844.24..2679748.70 rows=3161784 width=20) (actual time=39986.781..39986.782 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=872662 read=485090 dirtied=774 written=768 -> HashAggregate (cost=2571901.38..2603519.22 rows=3161784 width=20) (actual time=39907.742..39966.364 rows=113585 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=872656 read=485090 dirtied=774 written=768 -> Hash Join (cost=551265.22..2524474.62 rows=3161784 width=20) (actual time=11461.940..39592.091 rows=298936 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=872656 read=485090 dirtied=774 written=768 -> Seq Scan on lineitem (cost=0.00..1818870.86 rows=32725520 width=12) (actual time=0.048..19627.257 rows=32566070 loops=1) Filter: (l_shipdate > '1995-03-07'::date) Rows Removed by Filter: 27479533 Buffers: shared hit=676871 read=390675 dirtied=774 written=758 -> Hash (cost=533113.67..533113.67 rows=1452124 width=12) (actual time=11441.045..11441.045 rows=1449910 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78685kB Buffers: shared hit=195785 read=94415 written=10 -> Hash Join (cost=49740.43..533113.67 rows=1452124 width=12) (actual time=917.279..10682.328 rows=1449910 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=195785 read=94415 written=10 -> Seq Scan on orders (cost=0.00..441649.60 rows=7253973 width=16) (actual time=0.039..5360.610 rows=7246881 loops=1) Filter: (o_orderdate < '1995-03-07'::date) Rows Removed by Filter: 7768119 Buffers: shared hit=195783 read=57992 written=10 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=912.159..912.159 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 -> Bitmap Heap Scan on customer (cost=6955.56..45987.00 rows=300275 width=4) (actual time=88.355..782.526 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36423 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.49 rows=300275 width=0) (actual time=76.571..76.571 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 4.788 ms Execution time: 40024.118 ms (38 rows) COMMIT; COMMIT