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-10' and l_shipdate > date '1995-03-10' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2698809.94..2698809.96 rows=10 width=20) (actual time=33777.136..33777.140 rows=10 loops=1) Buffers: shared hit=687397 read=684858 dirtied=970 written=631 -> Sort (cost=2698809.94..2706746.68 rows=3174696 width=20) (actual time=33777.133..33777.134 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=687397 read=684858 dirtied=970 written=631 -> HashAggregate (cost=2598458.94..2630205.90 rows=3174696 width=20) (actual time=33711.781..33757.301 rows=113118 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=687391 read=684858 dirtied=970 written=631 -> Hash Join (cost=556607.55..2550838.50 rows=3174696 width=20) (actual time=9353.477..33469.664 rows=298577 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=687391 read=684858 dirtied=970 written=631 -> Seq Scan on lineitem (cost=0.00..1838827.16 rows=32975153 width=12) (actual time=0.032..17868.890 rows=32489962 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27555335 Buffers: shared hit=562246 read=517016 dirtied=959 written=379 -> Hash (cost=538321.35..538321.35 rows=1462896 width=12) (actual time=9342.470..9342.470 rows=1449337 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78661kB Buffers: shared hit=125145 read=167842 dirtied=11 written=252 -> Hash Join (cost=49686.93..538321.35 rows=1462896 width=12) (actual time=756.207..8792.037 rows=1449337 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=125145 read=167842 dirtied=11 written=252 -> Seq Scan on orders (cost=0.00..446496.39 rows=7335752 width=16) (actual time=0.020..5019.941 rows=7265841 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7749159 Buffers: shared hit=125143 read=131417 dirtied=11 written=161 -> Hash (cost=45947.81..45947.81 rows=299130 width=4) (actual time=753.430..753.430 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 written=91 -> Bitmap Heap Scan on customer (cost=6930.69..45947.81 rows=299130 width=4) (actual time=70.637..657.303 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=91 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6855.90 rows=299130 width=0) (actual time=61.986..61.986 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 3.837 ms Execution time: 33801.521 ms (38 rows) COMMIT; COMMIT