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-16' and l_shipdate > date '1995-03-16' group by l_orderkey, o_orderdate, o_shippriority order by revenue desc, o_orderdate LIMIT 10; QUERY PLAN ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- Limit (cost=2686336.89..2686336.91 rows=10 width=20) (actual time=33557.439..33557.443 rows=10 loops=1) Buffers: shared hit=998578 read=367066 dirtied=1 written=45 -> Sort (cost=2686336.89..2694266.93 rows=3172019 width=20) (actual time=33557.436..33557.437 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=998578 read=367066 dirtied=1 written=45 -> HashAggregate (cost=2586070.50..2617790.69 rows=3172019 width=20) (actual time=33475.902..33535.663 rows=113437 loops=1) Group Key: lineitem.l_orderkey, orders.o_orderdate, orders.o_shippriority Buffers: shared hit=998572 read=367066 dirtied=1 written=45 -> Hash Join (cost=554597.52..2538490.22 rows=3172019 width=20) (actual time=8409.829..33210.646 rows=298913 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=998572 read=367066 dirtied=1 written=45 -> Seq Scan on lineitem (cost=0.00..1829722.15 rows=32653430 width=12) (actual time=0.053..18353.374 rows=32339464 loops=1) Filter: (l_shipdate > '1995-03-16'::date) Rows Removed by Filter: 27705200 Buffers: shared hit=746050 read=327868 -> Hash (cost=536237.69..536237.69 rows=1468786 width=12) (actual time=8393.523..8393.523 rows=1461161 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 79169kB Buffers: shared hit=252522 read=39198 dirtied=1 written=45 -> Hash Join (cost=49740.43..536237.69 rows=1468786 width=12) (actual time=837.175..7870.024 rows=1461161 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=252522 read=39198 dirtied=1 written=45 -> Seq Scan on orders (cost=0.00..444294.89 rows=7337203 width=16) (actual time=0.022..4634.801 rows=7303376 loops=1) Filter: (o_orderdate < '1995-03-16'::date) Rows Removed by Filter: 7711624 Buffers: shared hit=252515 read=2780 dirtied=1 written=3 -> Hash (cost=45987.00..45987.00 rows=300275 width=4) (actual time=833.099..833.099 rows=299496 loops=1) Buckets: 524288 Batches: 1 Memory Usage: 14626kB Buffers: shared hit=7 read=36418 written=42 -> Bitmap Heap Scan on customer (cost=6955.56..45987.00 rows=300275 width=4) (actual time=76.989..737.689 rows=299496 loops=1) Recheck Cond: (c_mktsegment = 'FURNITURE'::bpchar) Heap Blocks: exact=35275 Buffers: shared hit=7 read=36418 written=42 -> Bitmap Index Scan on customer_c_mktsegment_c_custkey_idx (cost=0.00..6880.49 rows=300275 width=0) (actual time=68.038..68.038 rows=299496 loops=1) Index Cond: (c_mktsegment = 'FURNITURE'::bpchar) Buffers: shared read=1150 written=4 Planning time: 4.212 ms Execution time: 33595.836 ms (38 rows) COMMIT; COMMIT