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-28' and l_shipdate > date '1995-03-28' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2669417.56..2669417.59 rows=10 width=20) (actual time=28625.385..28625.389 rows=10 loops=1) Buffers: shared hit=1105586 read=252166 dirtied=31 written=34 -> Sort (cost=2669417.56..2677278.41 rows=3144339 width=20) (actual time=28625.382..28625.384 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=1105586 read=252166 dirtied=31 written=34 -> HashAggregate (cost=2570026.13..2601469.52 rows=3144339 width=20) (actual time=28559.351..28605.685 rows=113311 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1105580 read=252166 dirtied=31 written=34 -> Hash Join (cost=552093.90..2522861.05 rows=3144339 width=20) (actual time=7119.738..28331.526 rows=299151 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1105580 read=252166 dirtied=31 written=34 -> Seq Scan on lineitem (cost=0.00..1818872.36 rows=32120373 width=12) (actual time=0.034..16309.376 rows=32040389 loops=1) Filter: (l_shipdate > '1995-03-28'::date) Rows Removed by Filter: 28005214 Buffers: shared hit=863178 read=204368 -> Hash (cost=533702.41..533702.41 rows=1471319 width=12) (actual time=7107.736..7107.736 rows=1476078 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79810kB Buffers: shared hit=242402 read=47798 dirtied=31 written=34 -> Hash Join (cost=49701.25..533702.41 rows=1471319 width=12) (actual time=695.931..6632.883 rows=1476078 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=242402 read=47798 dirtied=31 written=34 -> Seq Scan on orders (cost=0.00..441649.60 rows=7370232 width=16) (actual time=0.017..3826.965 rows=7377947 loops=1) Filter: (o_orderdate < '1995-03-28'::date) Rows Removed by Filter: 7637053 Buffers: shared hit=242399 read=11376 dirtied=31 -> Hash (cost=45958.19..45958.19 rows=299445 width=4) (actual time=692.981..692.981 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=3 read=36422 written=34 -> Bitmap Heap Scan on customer (cost=6937.13..45958.19 rows=299445 width=4) (actual time=67.674..604.577 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=3 read=36422 written=34 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6862.26 rows=299445 width=0) (actual time=59.561..59.561 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 Planning time: 3.283 ms Execution time: 28653.613 ms (38 rows) COMMIT; COMMIT