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) > 312 ) 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=10173596.01..10173598.76 rows=100 width=39) (actual time=101574.877..101575.191 rows=100 loops=1) Buffers: shared hit=1826481 read=600053 written=26 -> GroupAggregate (cost=10173596.01..11000876.97 rows=30082944 width=39) (actual time=101574.873..101575.177 rows=100 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1826481 read=600053 written=26 -> Sort (cost=10173596.01..10248803.37 rows=30082944 width=39) (actual time=101574.852..101574.892 rows=701 loops=1) Sort Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Sort Method: quicksort Memory: 85kB Buffers: shared hit=1826481 read=600053 written=26 -> Hash Join (cost=2891176.59..5614346.49 rows=30082944 width=39) (actual time=78464.550..101573.239 rows=777 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1826469 read=600053 written=26 -> Seq Scan on lineitem (cost=0.00..1670266.87 rows=60165887 width=8) (actual time=0.047..11395.890 rows=60045379 loops=1) Buffers: shared hit=981498 read=87110 written=3 -> Hash (cost=2797145.64..2797145.64 rows=7522476 width=39) (actual time=78347.828..78347.828 rows=111 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65544kB Buffers: shared hit=844971 read=512943 written=23 -> Hash Join (cost=2182681.72..2797145.64 rows=7522476 width=39) (actual time=69222.608..78342.574 rows=111 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=844971 read=512943 written=23 -> Hash Join (cost=2113653.72..2615280.50 rows=7522476 width=20) (actual time=67919.110..77031.782 rows=111 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=844969 read=477667 written=1 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=16) (actual time=0.010..3311.681 rows=15015000 loops=1) Buffers: shared hit=251865 read=2163 written=1 -> Hash (cost=2062740.36..2062740.36 rows=4073069 width=4) (actual time=67715.325..67715.325 rows=111 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32772kB Buffers: shared hit=593104 read=475504 -> HashAggregate (cost=1971096.31..2022009.67 rows=4073069 width=8) (actual time=55252.035..67711.686 rows=111 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 312::double precision) Rows Removed by Filter: 15014889 Buffers: shared hit=593104 read=475504 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1670266.87 rows=60165887 width=8) (actual time=0.013..14057.184 rows=60045379 loops=1) Buffers: shared hit=593104 read=475504 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1291.307..1291.307 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=2 read=35276 written=22 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.013..803.723 rows=1500000 loops=1) Buffers: shared hit=2 read=35276 written=22 Planning time: 5.152 ms Execution time: 101878.853 ms (42 rows) COMMIT; COMMIT