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-31' and l_shipdate > date '1995-03-31' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2817665.17..2817665.20 rows=10 width=20) (actual time=115390.978..115390.983 rows=10 loops=1) Buffers: shared hit=748530 read=625034 dirtied=298 written=21 -> Sort (cost=2817665.17..2825670.26 rows=3202034 width=20) (actual time=115390.973..115390.976 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=748530 read=625034 dirtied=298 written=21 -> HashAggregate (cost=2716450.03..2748470.37 rows=3202034 width=20) (actual time=115290.125..115367.645 rows=113371 loops=1) Buffers: shared hit=748524 read=625034 dirtied=298 written=21 -> Hash Join (cost=633537.03..2668419.52 rows=3202034 width=20) (actual time=36738.130..114663.190 rows=299261 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=748524 read=625034 dirtied=298 written=21 -> Seq Scan on lineitem (cost=0.00..1840629.69 rows=32446492 width=12) (actual time=0.052..50208.625 rows=31964916 loops=1) Filter: (l_shipdate > '1995-03-31'::date) Rows Removed by Filter: 28080117 Buffers: shared hit=507635 read=572684 -> Hash (cost=614774.37..614774.37 rows=1501013 width=12) (actual time=36735.757..36735.757 rows=1479824 loops=1) Buckets: 262144 Batches: 1 Memory Usage: 63587kB Buffers: shared hit=240889 read=52350 dirtied=298 written=21 -> Hash Join (cost=49746.29..614774.37 rows=1501013 width=12) (actual time=2810.541..34454.604 rows=1479824 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=240889 read=52350 dirtied=298 written=21 -> Seq Scan on orders (cost=0.00..446936.69 rows=7496819 width=16) (actual time=0.020..10904.654 rows=7396635 loops=1) Filter: (o_orderdate < '1995-03-31'::date) Rows Removed by Filter: 7618365 Buffers: shared hit=226413 read=30400 dirtied=298 written=21 -> Hash (cost=45992.16..45992.16 rows=300330 width=4) (actual time=2810.267..2810.267 rows=299496 loops=1) Buckets: 32768 Batches: 1 Memory Usage: 10530kB Buffers: shared hit=14476 read=21950 -> Bitmap Heap Scan on customer (cost=6960.04..45992.16 rows=300330 width=4) (actual time=208.662..2592.806 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared hit=14476 read=21950 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6884.96 rows=300330 width=0) (actual time=196.563..196.563 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1151 Total runtime: 115444.288 ms (35 rows) COMMIT; COMMIT