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-04' and l_shipdate > date '1995-03-04' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2667677.21..2667677.24 rows=10 width=20) (actual time=39567.861..39567.866 rows=10 loops=1) Buffers: shared hit=837373 read=519055 dirtied=252 written=2324 -> Sort (cost=2667677.21..2675526.11 rows=3139559 width=20) (actual time=39567.858..39567.858 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=837373 read=519055 dirtied=252 written=2324 -> HashAggregate (cost=2568436.88..2599832.47 rows=3139559 width=20) (actual time=39490.186..39546.975 rows=113488 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=837367 read=519055 dirtied=252 written=2324 -> Hash Join (cost=550589.37..2521343.50 rows=3139559 width=20) (actual time=12119.035..39205.311 rows=298876 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=837367 read=519055 dirtied=252 written=2324 -> Seq Scan on lineitem (cost=0.00..1817047.86 rows=32616181 width=12) (actual time=0.016..19053.534 rows=32608233 loops=1) Filter: (l_shipdate > '1995-03-04'::date) Rows Removed by Filter: 27377096 Buffers: shared hit=646350 read=420125 written=4 -> Hash (cost=532523.02..532523.02 rows=1445308 width=12) (actual time=12110.528..12110.528 rows=1444679 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78461kB Buffers: shared hit=191017 read=98930 dirtied=252 written=2320 -> Hash Join (cost=49689.56..532523.02 rows=1445308 width=12) (actual time=797.870..11418.821 rows=1444679 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=191017 read=98930 dirtied=252 written=2320 -> Seq Scan on orders (cost=0.00..441209.30 rows=7245622 width=16) (actual time=0.015..6043.665 rows=7220748 loops=1) Filter: (o_orderdate < '1995-03-04'::date) Rows Removed by Filter: 7779252 Buffers: shared hit=156444 read=97078 dirtied=252 written=2320 -> Hash (cost=45949.43..45949.43 rows=299210 width=4) (actual time=795.400..795.400 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=34573 read=1852 -> Bitmap Heap Scan on customer (cost=6931.30..45949.43 rows=299210 width=4) (actual time=110.143..642.312 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=34573 read=1852 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6856.50 rows=299210 width=0) (actual time=97.040..97.040 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 6.420 ms Execution time: 39589.012 ms (38 rows) COMMIT; COMMIT