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 = 'HOUSEHOLD' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-16' and l_shipdate > date '1995-03-16' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2766010.35..2766010.37 rows=10 width=20) (actual time=72304.292..72304.295 rows=10 loops=1) Buffers: shared hit=486854 read=881427 dirtied=1050 written=1053 -> Sort (cost=2766010.35..2773975.98 rows=3186252 width=20) (actual time=72304.287..72304.289 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=486854 read=881427 dirtied=1050 written=1053 -> HashAggregate (cost=2665294.06..2697156.58 rows=3186252 width=20) (actual time=72221.305..72283.799 rows=113109 loops=1) Buffers: shared hit=486848 read=881427 dirtied=1050 written=1053 -> Hash Join (cost=629764.66..2617500.28 rows=3186252 width=20) (actual time=23892.299..71803.484 rows=298445 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=486848 read=881427 dirtied=1050 written=1053 -> Seq Scan on lineitem (cost=0.00..1833346.69 rows=32673712 width=12) (actual time=0.057..24879.507 rows=32338914 loops=1) Filter: (l_shipdate > '1995-03-16'::date) Rows Removed by Filter: 27705262 Buffers: shared hit=217283 read=858763 dirtied=1050 written=1051 -> Hash (cost=611297.37..611297.37 rows=1477383 width=12) (actual time=23890.132..23890.132 rows=1456923 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62603kB Buffers: shared hit=269565 read=22664 written=2 -> Hash Join (cost=49722.08..611297.37 rows=1477383 width=12) (actual time=975.899..23141.081 rows=1456923 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=269565 read=22664 written=2 -> Seq Scan on orders (cost=0.00..445175.49 rows=7390980 width=16) (actual time=0.014..6086.030 rows=7303439 loops=1) Filter: (o_orderdate < '1995-03-16'::date) Rows Removed by Filter: 7711561 Buffers: shared hit=253963 read=1838 written=2 -> Hash (cost=45974.14..45974.14 rows=299835 width=4) (actual time=975.653..975.653 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=15602 read=20826 -> Bitmap Heap Scan on customer (cost=6948.20..45974.14 rows=299835 width=4) (actual time=115.351..813.257 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=15602 read=20826 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6873.24 rows=299835 width=0) (actual time=101.998..101.998 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 72357.244 ms (35 rows) COMMIT; COMMIT