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-05' and l_shipdate > date '1995-03-05' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2697939.03..2697939.05 rows=10 width=20) (actual time=35292.794..35292.798 rows=10 loops=1) Buffers: shared hit=745327 read=625599 dirtied=1 written=89 -> Sort (cost=2697939.03..2705918.16 rows=3191652 width=20) (actual time=35292.790..35292.793 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=745327 read=625599 dirtied=1 written=89 -> HashAggregate (cost=2597052.06..2628968.58 rows=3191652 width=20) (actual time=35210.070..35271.338 rows=113541 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=745321 read=625599 dirtied=1 written=89 -> Hash Join (cost=556165.38..2549177.27 rows=3191652 width=20) (actual time=8846.600..34933.833 rows=299203 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=745321 read=625599 dirtied=1 written=89 -> Seq Scan on lineitem (cost=0.00..1837002.56 rows=33091417 width=12) (actual time=0.060..18636.567 rows=32614932 loops=1) Filter: (l_shipdate > '1995-03-05'::date) Rows Removed by Filter: 27430062 Buffers: shared hit=552408 read=525780 dirtied=1 written=1 -> Hash (cost=537864.17..537864.17 rows=1464097 width=12) (actual time=8835.250..8835.250 rows=1447458 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78580kB Buffers: shared hit=192913 read=99819 written=88 -> Hash Join (cost=49740.43..537864.17 rows=1464097 width=12) (actual time=813.229..8341.246 rows=1447458 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=192913 read=99819 written=88 -> Seq Scan on orders (cost=0.00..446056.09 rows=7313780 width=16) (actual time=0.025..5108.089 rows=7234387 loops=1) Filter: (o_orderdate < '1995-03-05'::date) Rows Removed by Filter: 7780613 Buffers: shared hit=192911 read=63396 written=46 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=810.049..810.049 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=2 read=36423 written=42 -> Bitmap Heap Scan on customer (cost=6955.56..45987.00 rows=300275 width=4) (actual time=79.158..716.786 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=2 read=36423 written=42 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.49 rows=300275 width=0) (actual time=69.700..69.700 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=4 Planning time: 4.224 ms Execution time: 35318.785 ms (38 rows) COMMIT; COMMIT