BEGIN; BEGIN EXPLAIN (ANALYZE, BUFFERS) select c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice, sum(l_quantity) from customer, orders, lineitem where o_orderkey in ( select l_orderkey from lineitem group by l_orderkey having sum(l_quantity) > 315 ) and c_custkey = o_custkey and o_orderkey = l_orderkey group by c_name, c_custkey, o_orderkey, o_orderdate, o_totalprice order by o_totalprice desc, o_orderdate LIMIT 100; QUERY PLAN ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ Limit (cost=10243159.14..10243161.89 rows=100 width=39) (actual time=70809.750..70810.006 rows=75 loops=1) Buffers: shared hit=1384565 read=1058614 written=228 -> GroupAggregate (cost=10243159.14..11076196.40 rows=30292264 width=39) (actual time=70809.747..70809.997 rows=75 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1384565 read=1058614 written=228 -> Sort (cost=10243159.14..10318889.80 rows=30292264 width=39) (actual time=70809.738..70809.776 rows=525 loops=1) Sort Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Sort Method: quicksort Memory: 66kB Buffers: shared hit=1384565 read=1058614 written=228 -> Hash Join (cost=2908549.82..5650668.36 rows=30292264 width=39) (actual time=51781.731..70809.038 rows=525 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1384553 read=1058614 written=228 -> Seq Scan on lineitem (cost=0.00..1681889.28 rows=60584528 width=8) (actual time=0.048..9299.986 rows=60044176 loops=1) Buffers: shared hit=441281 read=634763 written=2 -> Hash (cost=2813862.57..2813862.57 rows=7574980 width=39) (actual time=51672.484..51672.484 rows=75 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=943272 read=423851 written=226 -> Hash Join (cost=2195617.15..2813862.57 rows=7574980 width=39) (actual time=45661.406..51672.332 rows=75 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=943272 read=423851 written=226 -> Hash Join (cost=2126589.15..2631209.87 rows=7574980 width=20) (actual time=44752.839..50763.553 rows=75 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=907994 read=423851 written=226 -> Seq Scan on orders (cost=0.00..407300.59 rows=15149959 width=16) (actual time=0.006..2768.863 rows=15015000 loops=1) Buffers: shared hit=191437 read=64364 written=226 -> Hash (cost=2075954.43..2075954.43 rows=4050778 width=4) (actual time=44664.117..44664.117 rows=75 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=716557 read=359487 -> HashAggregate (cost=1984811.92..2035446.65 rows=4050778 width=8) (actual time=38730.169..44663.965 rows=75 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 315::double precision) Rows Removed by Filter: 15014925 Buffers: shared hit=716557 read=359487 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1681889.28 rows=60584528 width=8) (actual time=0.004..8802.000 rows=60044176 loops=1) Buffers: shared hit=716557 read=359487 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=898.282..898.282 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=35278 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.013..441.120 rows=1500000 loops=1) Buffers: shared hit=35278 Planning time: 4.020 ms Execution time: 70932.647 ms (42 rows) COMMIT; COMMIT