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 = 'FURNITURE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-14' and l_shipdate > date '1995-03-14' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2686481.52..2686481.54 rows=10 width=20) (actual time=34710.390..34710.394 rows=10 loops=1) Buffers: shared hit=748439 read=617205 written=134 -> Sort (cost=2686481.52..2694414.77 rows=3173303 width=20) (actual time=34710.386..34710.388 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=748439 read=617205 written=134 -> HashAggregate (cost=2586174.55..2617907.58 rows=3173303 width=20) (actual time=34630.293..34688.921 rows=113414 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=748433 read=617205 written=134 -> Hash Join (cost=554591.34..2538575.00 rows=3173303 width=20) (actual time=9035.937..34360.972 rows=298684 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=748433 read=617205 written=134 -> Seq Scan on lineitem (cost=0.00..1829728.70 rows=32672515 width=12) (actual time=0.049..19098.954 rows=32389697 loops=1) Filter: (l_shipdate > '1995-03-14'::date) Rows Removed by Filter: 27654967 Buffers: shared hit=537275 read=536643 written=1 -> Hash (cost=536234.82..536234.82 rows=1468522 width=12) (actual time=9021.212..9021.212 rows=1458622 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79060kB Buffers: shared hit=211158 read=80562 written=133 -> Hash Join (cost=49737.81..536234.82 rows=1468522 width=12) (actual time=770.041..8486.356 rows=1458622 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=211158 read=80562 written=133 -> Seq Scan on orders (cost=0.00..444294.89 rows=7337839 width=16) (actual time=0.026..5268.811 rows=7290745 loops=1) Filter: (o_orderdate < '1995-03-14'::date) Rows Removed by Filter: 7724255 Buffers: shared hit=180292 read=75003 written=124 -> Hash (cost=45985.38..45985.38 rows=300195 width=4) (actual time=767.199..767.199 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=30866 read=5559 written=9 -> Bitmap Heap Scan on customer (cost=6954.94..45985.38 rows=300195 width=4) (actual time=73.657..666.608 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=30866 read=5559 written=9 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.89 rows=300195 width=0) (actual time=64.747..64.747 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 3.504 ms Execution time: 34764.050 ms (38 rows) COMMIT; COMMIT