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-02' and l_shipdate > date '1995-03-02' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2683469.02..2683469.05 rows=10 width=20) (actual time=35745.988..35745.991 rows=10 loops=1) Buffers: shared hit=731393 read=632935 dirtied=887 written=672 -> Sort (cost=2683469.02..2691365.84 rows=3158728 width=20) (actual time=35745.985..35745.986 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=731393 read=632935 dirtied=887 written=672 -> HashAggregate (cost=2583622.77..2615210.05 rows=3158728 width=20) (actual time=35655.365..35725.361 rows=113602 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=731387 read=632935 dirtied=887 written=672 -> Hash Join (cost=553508.05..2536241.85 rows=3158728 width=20) (actual time=9812.618..35388.838 rows=299174 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=731387 read=632935 dirtied=887 written=672 -> Seq Scan on lineitem (cost=0.00..1827919.74 rows=32860475 width=12) (actual time=0.054..18569.496 rows=32690822 loops=1) Filter: (l_shipdate > '1995-03-02'::date) Rows Removed by Filter: 27354488 Buffers: shared hit=563965 read=508891 dirtied=887 written=672 -> Hash (cost=535358.42..535358.42 rows=1451970 width=12) (actual time=9795.329..9795.329 rows=1443577 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78413kB Buffers: shared hit=167422 read=124044 -> Hash Join (cost=49689.56..535358.42 rows=1451970 width=12) (actual time=891.034..9131.797 rows=1443577 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=167422 read=124044 -> Seq Scan on orders (cost=0.00..443852.85 rows=7279018 width=16) (actual time=0.027..5170.106 rows=7215395 loops=1) Filter: (o_orderdate < '1995-03-02'::date) Rows Removed by Filter: 7799605 Buffers: shared hit=167420 read=87621 -> Hash (cost=45949.43..45949.43 rows=299210 width=4) (actual time=887.099..887.099 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 -> Bitmap Heap Scan on customer (cost=6931.30..45949.43 rows=299210 width=4) (actual time=77.758..770.722 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..6856.50 rows=299210 width=0) (actual time=68.643..68.643 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 4.420 ms Execution time: 35774.248 ms (38 rows) COMMIT; COMMIT