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-14' and l_shipdate > date '1995-03-14' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2670647.60..2670647.63 rows=10 width=20) (actual time=33157.401..33157.405 rows=10 loops=1) Buffers: shared hit=878546 read=479206 dirtied=253 -> Sort (cost=2670647.60..2678526.36 rows=3151502 width=20) (actual time=33157.398..33157.400 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=878546 read=479206 dirtied=253 -> HashAggregate (cost=2571029.75..2602544.77 rows=3151502 width=20) (actual time=33041.304..33135.367 rows=113449 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=878540 read=479206 dirtied=253 -> Hash Join (cost=551468.16..2523757.22 rows=3151502 width=20) (actual time=8623.093..32434.156 rows=298836 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=878540 read=479206 dirtied=253 -> Seq Scan on lineitem (cost=0.00..1818865.65 rows=32508904 width=12) (actual time=0.033..17889.745 rows=32391112 loops=1) Filter: (l_shipdate > '1995-03-14'::date) Rows Removed by Filter: 27654491 Buffers: shared hit=710739 read=356807 -> Hash (cost=533255.09..533255.09 rows=1457046 width=12) (actual time=8612.150..8612.150 rows=1458608 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79059kB Buffers: shared hit=167801 read=122399 dirtied=253 -> Hash Join (cost=49740.43..533255.09 rows=1457046 width=12) (actual time=803.931..8073.857 rows=1458608 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=167801 read=122399 dirtied=253 -> Seq Scan on orders (cost=0.00..441649.60 rows=7278559 width=16) (actual time=0.023..4869.034 rows=7290563 loops=1) Filter: (o_orderdate < '1995-03-14'::date) Rows Removed by Filter: 7724437 Buffers: shared hit=167799 read=85976 dirtied=253 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=801.155..801.155 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=72.635..708.559 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=63.890..63.890 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 4.017 ms Execution time: 33873.976 ms (38 rows) COMMIT; COMMIT