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-27' and l_shipdate > date '1995-03-27' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2699669.89..2699669.92 rows=10 width=20) (actual time=38674.110..38674.115 rows=10 loops=1) Buffers: shared hit=861851 read=510404 written=233 -> Sort (cost=2699669.89..2707660.39 rows=3196198 width=20) (actual time=38674.106..38674.107 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=861851 read=510404 written=233 -> HashAggregate (cost=2598639.22..2630601.20 rows=3196198 width=20) (actual time=38593.856..38653.533 rows=113148 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=861845 read=510404 written=233 -> Hash Join (cost=557732.81..2550696.25 rows=3196198 width=20) (actual time=10120.883..38296.981 rows=298338 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=861845 read=510404 written=233 -> Seq Scan on lineitem (cost=0.00..1838832.43 rows=32578412 width=12) (actual time=0.041..19768.537 rows=32064791 loops=1) Filter: (l_shipdate > '1995-03-27'::date) Rows Removed by Filter: 27980506 Buffers: shared hit=705356 read=373906 written=2 -> Hash (cost=539098.56..539098.56 rows=1490740 width=12) (actual time=10104.191..10104.191 rows=1470491 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79570kB Buffers: shared hit=156489 read=136498 written=231 -> Hash Join (cost=49712.62..539098.56 rows=1490740 width=12) (actual time=625.781..9323.559 rows=1470491 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=156489 read=136498 written=231 -> Seq Scan on orders (cost=0.00..446496.39 rows=7461906 width=16) (actual time=0.028..5704.575 rows=7371973 loops=1) Filter: (o_orderdate < '1995-03-27'::date) Rows Removed by Filter: 7643027 Buffers: shared hit=131498 read=125062 written=231 -> Hash (cost=45966.74..45966.74 rows=299670 width=4) (actual time=622.310..622.310 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=24991 read=11436 -> Bitmap Heap Scan on customer (cost=6942.87..45966.74 rows=299670 width=4) (actual time=77.719..528.958 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=24991 read=11436 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6867.95 rows=299670 width=0) (actual time=68.050..68.050 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 4.202 ms Execution time: 38701.652 ms (38 rows) COMMIT; COMMIT