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-15' and l_shipdate > date '1995-03-15' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2537263.89..2537263.92 rows=10 width=20) (actual time=33794.991..33794.992 rows=10 loops=1) Buffers: shared hit=1315486 read=42324 dirtied=1061 written=1910 -> Sort (cost=2537263.89..2545178.63 rows=3165896 width=20) (actual time=33794.988..33794.989 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=1315486 read=42324 dirtied=1061 written=1910 -> HashAggregate (cost=2437191.06..2468850.02 rows=3165896 width=20) (actual time=33725.950..33773.939 rows=113142 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1315480 read=42324 dirtied=1061 written=1910 -> Hash Join (cost=763504.76..2389702.62 rows=3165896 width=20) (actual time=7672.215..33456.052 rows=298489 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1315480 read=42324 dirtied=1061 written=1910 -> Bitmap Heap Scan on lineitem (cost=251484.51..1724408.97 rows=32430517 width=12) (actual time=118.680..20271.975 rows=32365888 loops=1) Recheck Cond: (l_shipdate > '1995-03-15'::date) Rows Removed by Index Recheck: 27679715 Heap Blocks: lossy=1067543 Buffers: shared hit=1026474 read=41117 dirtied=1061 written=1910 -> Bitmap Index Scan on lineitem_l_shipdate_l_suppkey_brin_idx (cost=0.00..243376.88 rows=32430517 width=0) (actual time=117.933..117.933 rows=10676480 loops=1) Index Cond: (l_shipdate > '1995-03-15'::date) Buffers: shared hit=48 -> Hash (cost=493679.76..493679.76 rows=1467239 width=12) (actual time=7543.473..7543.473 rows=1455536 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78927kB Buffers: shared hit=289006 read=1207 -> Hash Join (cost=106466.58..493679.76 rows=1467239 width=12) (actual time=415.989..7044.416 rows=1455536 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=289006 read=1207 -> Bitmap Heap Scan on orders (cost=56682.15..401815.45 rows=7308664 width=16) (actual time=27.331..4265.993 rows=7296925 loops=1) Recheck Cond: (o_orderdate < '1995-03-15'::date) Rows Removed by Index Recheck: 7718075 Heap Blocks: lossy=253775 Buffers: shared hit=253780 read=6 -> Bitmap Index Scan on orders_o_orderkey_o_orderdate_brin_idx (cost=0.00..54854.98 rows=7308664 width=0) (actual time=27.169..27.169 rows=2538240 loops=1) Index Cond: (o_orderdate < '1995-03-15'::date) Buffers: shared hit=5 read=6 -> Hash (cost=46020.31..46020.31 rows=301130 width=4) (actual time=386.230..386.230 rows=299751 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14635kB Buffers: shared hit=35226 read=1201 -> Bitmap Heap Scan on customer (cost=6978.19..46020.31 rows=301130 width=4) (actual time=75.105..308.145 rows=299751 loops=1) Recheck Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35226 read=1201 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6902.90 rows=301130 width=0) (actual time=66.361..66.361 rows=299751 loops=1) Index Cond: (c_mktsegment = 'HOUSEHOLD'::bpchar) Buffers: shared hit=2 read=1150 Planning time: 2.937 ms Execution time: 33816.296 ms (46 rows) COMMIT; COMMIT