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-20' and l_shipdate > date '1995-03-20' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2672693.86..2672693.88 rows=10 width=20) (actual time=31272.856..31272.859 rows=10 loops=1) Buffers: shared hit=623114 read=735955 -> Sort (cost=2672693.86..2680571.69 rows=3151131 width=20) (actual time=31272.850..31272.852 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=623114 read=735955 -> HashAggregate (cost=2573087.74..2604599.05 rows=3151131 width=20) (actual time=31204.593..31254.101 rows=113020 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=623108 read=735955 -> Hash Join (cost=552351.23..2525820.78 rows=3151131 width=20) (actual time=8636.110..30982.805 rows=298290 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=623108 read=735955 -> Seq Scan on lineitem (cost=0.00..1820677.48 rows=32341536 width=12) (actual time=0.063..16518.225 rows=32207961 loops=1) Filter: (l_shipdate > '1995-03-20'::date) Rows Removed by Filter: 27777692 Buffers: shared hit=538847 read=529761 -> Hash (cost=534027.81..534027.81 rows=1465874 width=12) (actual time=8620.977..8620.977 rows=1460356 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79134kB Buffers: shared hit=84261 read=206194 -> Hash Join (cost=49659.61..534027.81 rows=1465874 width=12) (actual time=676.819..8003.158 rows=1460356 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=84261 read=206194 -> Seq Scan on orders (cost=0.00..442089.90 rows=7365214 width=16) (actual time=0.013..4808.937 rows=7320993 loops=1) Filter: (o_orderdate < '1995-03-20'::date) Rows Removed by Filter: 7679007 Buffers: shared hit=84259 read=169769 -> Hash (cost=45927.86..45927.86 rows=298540 width=4) (actual time=673.237..673.237 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=2 read=36425 -> Bitmap Heap Scan on customer (cost=6918.11..45927.86 rows=298540 width=4) (actual time=68.011..570.847 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6843.48 rows=298540 width=0) (actual time=59.662..59.662 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared read=1152 Planning time: 6.007 ms Execution time: 31296.888 ms (38 rows) COMMIT; COMMIT