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-05' and l_shipdate > date '1995-03-05' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2683300.58..2683300.61 rows=10 width=20) (actual time=32627.106..32627.110 rows=10 loops=1) Buffers: shared hit=916656 read=447674 dirtied=32 written=147 -> Sort (cost=2683300.58..2691192.81 rows=3156890 width=20) (actual time=32627.102..32627.103 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=916656 read=447674 dirtied=32 written=147 -> HashAggregate (cost=2583512.42..2615081.32 rows=3156890 width=20) (actual time=32560.847..32607.020 rows=113055 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=916650 read=447674 dirtied=32 written=147 -> Hash Join (cost=553497.07..2536159.07 rows=3156890 width=20) (actual time=8884.129..32308.059 rows=298590 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=916650 read=447674 dirtied=32 written=147 -> Seq Scan on lineitem (cost=0.00..1827919.27 rows=32846353 width=12) (actual time=0.032..17959.349 rows=32615583 loops=1) Filter: (l_shipdate > '1995-03-05'::date) Rows Removed by Filter: 27429727 Buffers: shared hit=716251 read=356605 dirtied=32 written=31 -> Hash (cost=535350.21..535350.21 rows=1451749 width=12) (actual time=8867.876..8867.876 rows=1443180 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78396kB Buffers: shared hit=200399 read=91069 written=116 -> Hash Join (cost=49696.83..535350.21 rows=1451749 width=12) (actual time=837.414..8315.175 rows=1443180 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=200399 read=91069 written=116 -> Seq Scan on orders (cost=0.00..443852.85 rows=7275478 width=16) (actual time=0.042..4926.291 rows=7234321 loops=1) Filter: (o_orderdate < '1995-03-05'::date) Rows Removed by Filter: 7780679 Buffers: shared hit=200396 read=54645 written=40 -> Hash (cost=45955.46..45955.46 rows=299310 width=4) (actual time=833.880..833.880 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=3 read=36424 written=76 -> Bitmap Heap Scan on customer (cost=6936.08..45955.46 rows=299310 width=4) (actual time=82.358..734.050 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=3 read=36424 written=76 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6861.25 rows=299310 width=0) (actual time=72.534..72.534 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=6 Planning time: 4.586 ms Execution time: 32668.265 ms (38 rows) COMMIT; COMMIT