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-06' and l_shipdate > date '1995-03-06' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2775525.83..2775525.85 rows=10 width=20) (actual time=84632.142..84632.146 rows=10 loops=1) Buffers: shared hit=902892 read=470672 -> Sort (cost=2775525.83..2783500.88 rows=3190023 width=20) (actual time=84632.138..84632.138 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=902892 read=470672 -> HashAggregate (cost=2674690.34..2706590.57 rows=3190023 width=20) (actual time=84546.792..84611.351 rows=113551 loops=1) Buffers: shared hit=902886 read=470672 -> Hash Join (cost=630515.44..2626840.00 rows=3190023 width=20) (actual time=26167.480..84025.575 rows=299158 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=902886 read=470672 -> Seq Scan on lineitem (cost=0.00..1840630.19 rows=33011772 width=12) (actual time=0.057..32081.638 rows=32589917 loops=1) Filter: (l_shipdate > '1995-03-06'::date) Rows Removed by Filter: 27455116 Buffers: shared hit=609647 read=470672 -> Hash (cost=612143.24..612143.24 rows=1469776 width=12) (actual time=26165.326..26165.326 rows=1448632 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 62246kB Buffers: shared hit=293239 -> Hash Join (cost=49773.94..612143.24 rows=1469776 width=12) (actual time=792.377..24487.924 rows=1448632 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=293239 -> Seq Scan on orders (cost=0.00..446936.69 rows=7326171 width=16) (actual time=0.025..6669.690 rows=7240737 loops=1) Filter: (o_orderdate < '1995-03-06'::date) Rows Removed by Filter: 7774263 Buffers: shared hit=256813 -> Hash (cost=46012.31..46012.31 rows=300930 width=4) (actual time=792.021..792.021 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=36426 -> Bitmap Heap Scan on customer (cost=6972.69..46012.31 rows=300930 width=4) (actual time=99.741..648.848 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=36426 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6897.46 rows=300930 width=0) (actual time=87.249..87.249 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=1151 Total runtime: 84676.668 ms (35 rows) COMMIT; COMMIT