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-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=2667380.55..2667380.58 rows=10 width=20) (actual time=30144.979..30144.984 rows=10 loops=1) Buffers: shared hit=801796 read=554634 -> Sort (cost=2667380.55..2675219.23 rows=3135473 width=20) (actual time=30144.976..30144.978 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=801796 read=554634 -> HashAggregate (cost=2568269.38..2599624.11 rows=3135473 width=20) (actual time=30083.304..30126.307 rows=113177 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=801790 read=554634 -> Hash Join (cost=550502.39..2521237.28 rows=3135473 width=20) (actual time=7715.188..29869.699 rows=298850 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=801790 read=554634 -> Seq Scan on lineitem (cost=0.00..1817040.90 rows=32623803 width=12) (actual time=0.026..16418.786 rows=32541562 loops=1) Filter: (l_shipdate > '1995-03-08'::date) Rows Removed by Filter: 27504107 Buffers: shared hit=512993 read=553482 -> Hash (cost=532463.77..532463.77 rows=1443090 width=12) (actual time=7700.137..7700.137 rows=1446872 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78555kB Buffers: shared hit=288797 read=1152 -> Hash Join (cost=49686.93..532463.77 rows=1443090 width=12) (actual time=469.090..7178.657 rows=1446872 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=288797 read=1152 -> Seq Scan on orders (cost=0.00..441209.30 rows=7236435 width=16) (actual time=0.017..4394.324 rows=7253170 loops=1) Filter: (o_orderdate < '1995-03-08'::date) Rows Removed by Filter: 7761830 Buffers: shared hit=253522 -> Hash (cost=45947.81..45947.81 rows=299130 width=4) (actual time=465.118..465.118 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35275 read=1152 -> Bitmap Heap Scan on customer (cost=6930.69..45947.81 rows=299130 width=4) (actual time=67.925..380.169 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6855.90 rows=299130 width=0) (actual time=59.494..59.494 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 5.812 ms Execution time: 30175.163 ms (38 rows) COMMIT; COMMIT