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-09' and l_shipdate > date '1995-03-09' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2700568.33..2700568.35 rows=10 width=20) (actual time=38357.760..38357.765 rows=10 loops=1) Buffers: shared hit=1052558 read=319695 dirtied=2 written=18 -> Sort (cost=2700568.33..2708561.58 rows=3197300 width=20) (actual time=38357.753..38357.754 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=1052558 read=319695 dirtied=2 written=18 -> HashAggregate (cost=2599502.83..2631475.83 rows=3197300 width=20) (actual time=38250.684..38335.948 rows=113518 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1052552 read=319695 dirtied=2 written=18 -> Hash Join (cost=556893.73..2551543.33 rows=3197300 width=20) (actual time=12685.473..37983.716 rows=299177 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1052552 read=319695 dirtied=2 written=18 -> Seq Scan on lineitem (cost=0.00..1838832.43 rows=33025113 width=12) (actual time=0.036..17724.756 rows=32515065 loops=1) Filter: (l_shipdate > '1995-03-09'::date) Rows Removed by Filter: 27530232 Buffers: shared hit=914508 read=164754 dirtied=2 written=13 -> Hash (cost=538505.19..538505.19 rows=1471083 width=12) (actual time=12669.263..12669.263 rows=1452522 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78798kB Buffers: shared hit=138044 read=154941 written=5 -> Hash Join (cost=49740.43..538505.19 rows=1471083 width=12) (actual time=894.896..11931.222 rows=1452522 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=138044 read=154941 written=5 -> Seq Scan on orders (cost=0.00..446496.39 rows=7348677 width=16) (actual time=0.039..5929.873 rows=7259713 loops=1) Filter: (o_orderdate < '1995-03-09'::date) Rows Removed by Filter: 7755287 Buffers: shared hit=138042 read=118518 written=5 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=890.363..890.363 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 -> Bitmap Heap Scan on customer (cost=6955.56..45987.00 rows=300275 width=4) (actual time=88.904..764.890 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36423 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.49 rows=300275 width=0) (actual time=76.211..76.211 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 4.573 ms Execution time: 38394.811 ms (38 rows) COMMIT; COMMIT