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 = 'AUTOMOBILE' and c_custkey = o_custkey and l_orderkey = o_orderkey and o_orderdate < date '1995-03-01' and l_shipdate > date '1995-03-01' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2570139.70..2570139.73 rows=10 width=20) (actual time=33107.835..33107.837 rows=10 loops=1) Buffers: shared hit=1228064 read=144248 written=198 -> Sort (cost=2570139.70..2578125.40 rows=3194280 width=20) (actual time=33107.832..33107.834 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=1228064 read=144248 written=198 -> HashAggregate (cost=2469169.66..2501112.46 rows=3194280 width=20) (actual time=33033.909..33086.701 rows=113722 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1228058 read=144248 written=198 -> Hash Join (cost=771487.02..2421255.46 rows=3194280 width=20) (actual time=10242.833..32786.133 rows=300105 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1228058 read=144248 written=198 -> Bitmap Heap Scan on lineitem (cost=257002.38..1750543.64 rows=33142501 width=12) (actual time=120.596..16832.100 rows=32682105 loops=1) Recheck Cond: (l_shipdate > '1995-03-01'::date) Rows Removed by Index Recheck: 27303433 Heap Blocks: lossy=1079260 Buffers: shared hit=1077049 read=2259 written=9 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..248716.75 rows=33142501 width=0) (actual time=119.839..119.839 rows=10792960 loops=1) Index Cond: (l_shipdate > '1995-03-01'::date) Buffers: shared hit=13 read=35 -> Hash (cost=496178.54..496178.54 rows=1464488 width=12) (actual time=10112.185..10112.185 rows=1440263 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78271kB Buffers: shared hit=151009 read=141989 written=189 -> Hash Join (cost=106377.34..496178.54 rows=1464488 width=12) (actual time=725.707..9519.555 rows=1440263 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=151009 read=141989 written=189 -> Bitmap Heap Scan on orders (cost=56601.32..404389.26 rows=7298235 width=16) (actual time=27.669..5958.461 rows=7202147 loops=1) Recheck Cond: (o_orderdate < '1995-03-01'::date) Rows Removed by Index Recheck: 7797853 Heap Blocks: lossy=256560 Buffers: shared hit=151007 read=105564 written=65 -> Bitmap Index Scan on orders_o_orderkey_o_orderdate_brin_idx (cost=0.00..54776.77 rows=7298235 width=0) (actual time=27.509..27.509 rows=2566400 loops=1) Index Cond: (o_orderdate < '1995-03-01'::date) Buffers: shared hit=3 read=8 -> Hash (cost=46013.58..46013.58 rows=300995 width=4) (actual time=695.630..695.630 rows=300036 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14645kB Buffers: shared hit=2 read=36425 written=124 -> Bitmap Heap Scan on customer (cost=6973.14..46013.58 rows=300995 width=4) (actual time=76.103..602.488 rows=300036 loops=1) Recheck Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36425 written=124 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6897.89 rows=300995 width=0) (actual time=67.193..67.193 rows=300036 loops=1) Index Cond: (c_mktsegment = 'AUTOMOBILE'::bpchar) Buffers: shared read=1152 written=3 Planning time: 3.703 ms Execution time: 33128.221 ms (46 rows) COMMIT; COMMIT