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-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2766326.19..2766326.22 rows=10 width=20) (actual time=59114.444..59114.448 rows=10 loops=1) Buffers: shared hit=979293 read=390315 -> Sort (cost=2766326.19..2774233.10 rows=3162764 width=20) (actual time=59114.440..59114.442 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=979293 read=390315 -> HashAggregate (cost=2666352.36..2697980.00 rows=3162764 width=20) (actual time=59046.367..59096.338 rows=112974 loops=1) Buffers: shared hit=979287 read=390315 -> Hash Join (cost=629445.66..2618910.90 rows=3162764 width=20) (actual time=21461.981..58737.628 rows=298067 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=979287 read=390315 -> Seq Scan on lineitem (cost=0.00..1835185.45 rows=32707239 width=12) (actual time=0.045..18979.214 rows=32332476 loops=1) Filter: (l_shipdate > '1995-03-15'::date) Rows Removed by Filter: 27652350 Buffers: shared hit=698740 read=378380 -> Hash (cost=611115.19..611115.19 rows=1466438 width=12) (actual time=21460.448..21460.448 rows=1454250 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62488kB Buffers: shared hit=280547 read=11935 -> Hash Join (cost=49678.57..611115.19 rows=1466438 width=12) (actual time=406.615..20430.910 rows=1454250 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=280547 read=11935 -> Seq Scan on orders (cost=0.00..445615.79 rows=7356833 width=16) (actual time=0.013..5187.141 rows=7289727 loops=1) Filter: (o_orderdate < '1995-03-15'::date) Rows Removed by Filter: 7710273 Buffers: shared hit=245387 read=10667 -> Hash (cost=45941.13..45941.13 rows=298995 width=4) (actual time=406.444..406.444 rows=299751 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10539kB Buffers: shared hit=35160 read=1268 -> Bitmap Heap Scan on customer (cost=6925.69..45941.13 rows=298995 width=4) (actual time=69.276..344.752 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=35160 read=1268 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6850.94 rows=298995 width=0) (actual time=61.688..61.688 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1153 Total runtime: 59151.143 ms (35 rows) COMMIT; COMMIT