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=2699012.38..2699012.40 rows=10 width=20) (actual time=34674.200..34674.206 rows=10 loops=1) Buffers: shared hit=708995 read=663258 written=71 -> Sort (cost=2699012.38..2706957.46 rows=3178031 width=20) (actual time=34674.196..34674.198 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=708995 read=663258 written=71 -> HashAggregate (cost=2598555.96..2630336.27 rows=3178031 width=20) (actual time=34605.772..34654.654 rows=113535 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=708989 read=663258 written=71 -> Hash Join (cost=556716.27..2550885.50 rows=3178031 width=20) (actual time=8442.547..34295.219 rows=299091 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=708989 read=663258 written=71 -> Seq Scan on lineitem (cost=0.00..1838834.20 rows=32947925 width=12) (actual time=0.056..17644.269 rows=32589805 loops=1) Filter: (l_shipdate > '1995-03-06'::date) Rows Removed by Filter: 27455492 Buffers: shared hit=525013 read=554249 -> Hash (cost=538395.73..538395.73 rows=1465643 width=12) (actual time=8430.966..8430.966 rows=1448718 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78634kB Buffers: shared hit=183976 read=109009 written=71 -> Hash Join (cost=49689.56..538395.73 rows=1465643 width=12) (actual time=434.413..7890.021 rows=1448718 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=183976 read=109009 written=71 -> Seq Scan on orders (cost=0.00..446496.39 rows=7347562 width=16) (actual time=0.024..5007.318 rows=7240784 loops=1) Filter: (o_orderdate < '1995-03-06'::date) Rows Removed by Filter: 7774216 Buffers: shared hit=148703 read=107857 written=71 -> Hash (cost=45949.43..45949.43 rows=299210 width=4) (actual time=431.531..431.531 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=35273 read=1152 -> Bitmap Heap Scan on customer (cost=6931.30..45949.43 rows=299210 width=4) (actual time=66.899..351.967 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35273 read=1152 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6856.50 rows=299210 width=0) (actual time=58.537..58.537 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 3.689 ms Execution time: 34704.968 ms (38 rows) COMMIT; COMMIT