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 = 'MACHINERY' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-05' and l_shipdate > date '1995-03-05' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2539899.68..2539899.70 rows=10 width=20) (actual time=38327.996..38328.000 rows=10 loops=1) Buffers: shared hit=1230575 read=127238 written=1188 -> Sort (cost=2539899.68..2547773.32 rows=3149459 width=20) (actual time=38327.993..38327.996 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=1230575 read=127238 written=1188 -> HashAggregate (cost=2440346.41..2471841.00 rows=3149459 width=20) (actual time=38259.108..38306.978 rows=113474 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1230569 read=127238 written=1188 -> Hash Join (cost=763255.84..2393104.53 rows=3149459 width=20) (actual time=8329.850..37960.980 rows=299781 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1230569 read=127238 written=1188 -> Bitmap Heap Scan on lineitem (cost=253304.06..1729163.28 rows=32665298 width=12) (actual time=120.642..23753.290 rows=32615916 loops=1) Recheck Cond: (l_shipdate > '1995-03-05'::date) Rows Removed by Index Recheck: 27429687 Heap Blocks: lossy=1067543 Buffers: shared hit=977062 read=90529 written=1188 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..245137.73 rows=32665298 width=0) (actual time=119.885..119.885 rows=10676480 loops=1) Index Cond: (l_shipdate > '1995-03-05'::date) Buffers: shared hit=48 -> Hash (cost=491837.66..491837.66 rows=1449130 width=12) (actual time=8202.789..8202.789 rows=1446355 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78533kB Buffers: shared hit=253507 read=36709 -> Hash Join (cost=105898.20..491837.66 rows=1449130 width=12) (actual time=1048.882..7717.586 rows=1446355 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=253507 read=36709 -> Bitmap Heap Scan on orders (cost=56161.04..400453.86 rows=7241425 width=16) (actual time=27.329..4343.973 rows=7234339 loops=1) Recheck Cond: (o_orderdate < '1995-03-05'::date) Rows Removed by Index Recheck: 7780661 Heap Blocks: lossy=253775 Buffers: shared hit=253453 read=333 -> Bitmap Index Scan on orders_o_orderkey_o_orderdate_brin_idx (cost=0.00..54350.69 rows=7241425 width=0) (actual time=27.171..27.171 rows=2538240 loops=1) Index Cond: (o_orderdate < '1995-03-05'::date) Buffers: shared hit=11 -> Hash (cost=45984.97..45984.97 rows=300175 width=4) (actual time=1019.559..1019.559 rows=300441 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14659kB Buffers: shared hit=54 read=36376 -> Bitmap Heap Scan on customer (cost=6954.78..45984.97 rows=300175 width=4) (actual time=77.281..923.495 rows=300441 loops=1) Recheck Cond: (c_mktsegment = 'MACHINERY'::bpchar) Heap Blocks: exact=35276 Buffers: shared hit=54 read=36376 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.74 rows=300175 width=0) (actual time=66.945..66.945 rows=300441 loops=1) Index Cond: (c_mktsegment = 'MACHINERY'::bpchar) Buffers: shared read=1154 Planning time: 3.153 ms Execution time: 38342.638 ms (46 rows) COMMIT; COMMIT