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 = 'BUILDING' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-16' and l_shipdate > date '1995-03-16' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2696913.86..2696913.89 rows=10 width=20) (actual time=37577.228..37577.233 rows=10 loops=1) Buffers: shared hit=875677 read=495255 written=61 -> Sort (cost=2696913.86..2704880.46 rows=3186639 width=20) (actual time=37577.225..37577.226 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=875677 read=495255 written=61 -> HashAggregate (cost=2596185.35..2628051.74 rows=3186639 width=20) (actual time=37505.943..37556.262 rows=114139 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=875671 read=495255 written=61 -> Hash Join (cost=556691.39..2548385.77 rows=3186639 width=20) (actual time=10807.759..37206.537 rows=302537 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=875671 read=495255 written=61 -> Seq Scan on lineitem (cost=0.00..1837003.88 rows=32753097 width=12) (actual time=0.030..19715.675 rows=32340072 loops=1) Filter: (l_shipdate > '1995-03-16'::date) Rows Removed by Filter: 27704922 Buffers: shared hit=613778 read=464410 written=1 -> Hash (cost=538230.18..538230.18 rows=1476897 width=12) (actual time=10792.105..10792.105 rows=1464520 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79313kB Buffers: shared hit=261893 read=30845 written=60 -> Hash Join (cost=49741.42..538230.18 rows=1476897 width=12) (actual time=543.614..10174.239 rows=1464520 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=261893 read=30845 written=60 -> Seq Scan on orders (cost=0.00..446056.09 rows=7376987 width=16) (actual time=0.024..5033.579 rows=7303246 loops=1) Filter: (o_orderdate < '1995-03-16'::date) Rows Removed by Filter: 7711754 Buffers: shared hit=230184 read=26123 written=53 -> Hash (cost=45987.60..45987.60 rows=300305 width=4) (actual time=539.920..539.920 rows=300276 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14653kB Buffers: shared hit=31709 read=4722 written=7 -> Bitmap Heap Scan on customer (cost=6955.79..45987.60 rows=300305 width=4) (actual time=77.551..437.678 rows=300276 loops=1) Recheck Cond: (c_mktsegment = 'BUILDING'::bpchar) Heap Blocks: exact=35277 Buffers: shared hit=31709 read=4722 written=7 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.72 rows=300305 width=0) (actual time=68.628..68.628 rows=300276 loops=1) Index Cond: (c_mktsegment = 'BUILDING'::bpchar) Buffers: shared read=1154 Planning time: 3.555 ms Execution time: 37605.332 ms (38 rows) COMMIT; COMMIT