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-01' and l_shipdate > date '1995-03-01' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2681560.90..2681560.92 rows=10 width=20) (actual time=37466.900..37466.902 rows=10 loops=1) Buffers: shared hit=745991 read=618339 written=42 -> Sort (cost=2681560.90..2689386.90 rows=3130403 width=20) (actual time=37466.896..37466.896 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=745991 read=618339 written=42 -> HashAggregate (cost=2582609.98..2613914.01 rows=3130403 width=20) (actual time=37371.513..37445.554 rows=113101 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=745985 read=618339 written=42 -> Hash Join (cost=552850.92..2535653.94 rows=3130403 width=20) (actual time=9676.480..37084.810 rows=298295 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=745985 read=618339 written=42 -> Seq Scan on lineitem (cost=0.00..1827915.45 rows=32955611 width=12) (actual time=0.039..20643.093 rows=32715887 loops=1) Filter: (l_shipdate > '1995-03-01'::date) Rows Removed by Filter: 27329423 Buffers: shared hit=588762 read=484094 -> Hash (cost=534915.97..534915.97 rows=1434796 width=12) (actual time=9667.448..9667.448 rows=1438173 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78181kB Buffers: shared hit=157223 read=134245 written=42 -> Hash Join (cost=49634.91..534915.97 rows=1434796 width=12) (actual time=899.624..9130.796 rows=1438173 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=157223 read=134245 written=42 -> Seq Scan on orders (cost=0.00..443852.85 rows=7221399 width=16) (actual time=0.043..5622.646 rows=7209069 loops=1) Filter: (o_orderdate < '1995-03-01'::date) Rows Removed by Filter: 7805931 Buffers: shared hit=157221 read=97820 written=26 -> Hash (cost=45909.54..45909.54 rows=298030 width=4) (actual time=896.838..896.838 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=16 -> Bitmap Heap Scan on customer (cost=6906.16..45909.54 rows=298030 width=4) (actual time=87.089..796.887 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=16 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6831.65 rows=298030 width=0) (actual time=77.366..77.366 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 written=1 Planning time: 4.226 ms Execution time: 37490.343 ms (38 rows) COMMIT; COMMIT