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-10' and l_shipdate > date '1995-03-10' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2700741.36..2700741.38 rows=10 width=20) (actual time=32708.518..32708.521 rows=10 loops=1) Buffers: shared hit=1022492 read=350342 dirtied=833 written=5997 -> Sort (cost=2700741.36..2708712.67 rows=3188524 width=20) (actual time=32708.512..32708.512 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=1022492 read=350342 dirtied=833 written=5997 -> HashAggregate (cost=2599953.26..2631838.50 rows=3188524 width=20) (actual time=32653.047..32689.810 rows=113392 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=1022486 read=350342 dirtied=833 written=5997 -> Hash Join (cost=556885.13..2552125.40 rows=3188524 width=20) (actual time=8951.547..32412.267 rows=299035 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1022486 read=350342 dirtied=833 written=5997 -> Seq Scan on lineitem (cost=0.00..1839823.65 rows=32941700 width=12) (actual time=0.031..17790.162 rows=32457285 loops=1) Filter: (l_shipdate > '1995-03-10'::date) Rows Removed by Filter: 27528253 Buffers: shared hit=842567 read=237276 dirtied=616 written=461 -> Hash (cost=538500.63..538500.63 rows=1470760 width=12) (actual time=8938.757..8938.757 rows=1452285 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 78787kB Buffers: shared hit=179919 read=113066 dirtied=217 written=5536 -> Hash Join (cost=49737.81..538500.63 rows=1470760 width=12) (actual time=511.835..8383.717 rows=1452285 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=179919 read=113066 dirtied=217 written=5536 -> Seq Scan on orders (cost=0.00..446496.39 rows=7349022 width=16) (actual time=0.031..5429.390 rows=7258690 loops=1) Filter: (o_orderdate < '1995-03-10'::date) Rows Removed by Filter: 7741310 Buffers: shared hit=144644 read=111916 dirtied=217 written=5443 -> Hash (cost=45985.38..45985.38 rows=300195 width=4) (actual time=509.008..509.008 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=35275 read=1150 written=93 -> Bitmap Heap Scan on customer (cost=6954.94..45985.38 rows=300195 width=4) (actual time=77.918..421.905 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=35275 read=1150 written=93 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6879.89 rows=300195 width=0) (actual time=68.679..68.679 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=93 Planning time: 3.922 ms Execution time: 32734.034 ms (38 rows) COMMIT; COMMIT