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-08' and l_shipdate > date '1995-03-08' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2670128.06..2670128.09 rows=10 width=20) (actual time=32026.515..32026.518 rows=10 loops=1) Buffers: shared hit=926962 read=430790 dirtied=253 -> Sort (cost=2670128.06..2677985.86 rows=3143119 width=20) (actual time=32026.511..32026.512 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=926962 read=430790 dirtied=253 -> HashAggregate (cost=2570775.20..2602206.39 rows=3143119 width=20) (actual time=31945.839..32006.014 rows=113620 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=926956 read=430790 dirtied=253 -> Hash Join (cost=551294.52..2523628.41 rows=3143119 width=20) (actual time=8250.680..31705.940 rows=299171 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=926956 read=430790 dirtied=253 -> Seq Scan on lineitem (cost=0.00..1818872.61 rows=32541358 width=12) (actual time=0.032..17886.745 rows=32541180 loops=1) Filter: (l_shipdate > '1995-03-08'::date) Rows Removed by Filter: 27504423 Buffers: shared hit=727648 read=339898 -> Hash (cost=533148.01..533148.01 rows=1451721 width=12) (actual time=8242.852..8242.852 rows=1451233 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78742kB Buffers: shared hit=199308 read=90892 dirtied=253 -> Hash Join (cost=49689.56..533148.01 rows=1451721 width=12) (actual time=754.836..7758.786 rows=1451233 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=199308 read=90892 dirtied=253 -> Seq Scan on orders (cost=0.00..441649.60 rows=7277771 width=16) (actual time=0.026..4624.224 rows=7253269 loops=1) Filter: (o_orderdate < '1995-03-08'::date) Rows Removed by Filter: 7761731 Buffers: shared hit=199306 read=54469 dirtied=253 -> Hash (cost=45949.43..45949.43 rows=299210 width=4) (actual time=752.437..752.437 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=71.552..660.862 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=62.640..62.640 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 3.838 ms Execution time: 32046.855 ms (38 rows) COMMIT; COMMIT