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-31' and l_shipdate > date '1995-03-31' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672327.39..2672327.42 rows=10 width=20) (actual time=35022.099..35022.104 rows=10 loops=1) Buffers: shared hit=822725 read=535891 written=1942 -> Sort (cost=2672327.39..2680244.54 rows=3166858 width=20) (actual time=35022.096..35022.099 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=822725 read=535891 written=1942 -> HashAggregate (cost=2572224.15..2603892.73 rows=3166858 width=20) (actual time=34918.447..35001.433 rows=113059 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=822719 read=535891 written=1942 -> Hash Join (cost=552711.60..2524721.28 rows=3166858 width=20) (actual time=9999.112..34627.243 rows=298135 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=822719 read=535891 written=1942 -> Seq Scan on lineitem (cost=0.00..1820341.29 rows=31999950 width=12) (actual time=0.049..18437.546 rows=31933966 loops=1) Filter: (l_shipdate > '1995-03-31'::date) Rows Removed by Filter: 28051586 Buffers: shared hit=575663 read=492745 -> Hash (cost=534118.69..534118.69 rows=1487433 width=12) (actual time=9979.307..9979.307 rows=1474034 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79722kB Buffers: shared hit=247056 read=43146 written=1942 -> Hash Join (cost=49751.80..534118.69 rows=1487433 width=12) (actual time=903.537..9310.851 rows=1474034 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=247056 read=43146 written=1942 -> Seq Scan on orders (cost=0.00..441649.60 rows=7424788 width=16) (actual time=0.023..4742.968 rows=7389038 loops=1) Filter: (o_orderdate < '1995-03-31'::date) Rows Removed by Filter: 7610962 Buffers: shared hit=247054 read=6721 written=343 -> Hash (cost=45995.55..45995.55 rows=300500 width=4) (actual time=899.174..899.174 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=1599 -> Bitmap Heap Scan on customer (cost=6961.30..45995.55 rows=300500 width=4) (actual time=80.892..775.736 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=1599 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6886.18 rows=300500 width=0) (actual time=71.961..71.961 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=38 Planning time: 4.001 ms Execution time: 35058.669 ms (38 rows) COMMIT; COMMIT