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=10173466.74..10173469.49 rows=100 width=39) (actual time=77051.610..77051.824 rows=75 loops=1) Buffers: shared hit=1537662 read=888872 dirtied=1078 written=7 -> GroupAggregate (cost=10173466.74..11000740.16 rows=30082670 width=39) (actual time=77051.607..77051.812 rows=75 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1537662 read=888872 dirtied=1078 written=7 -> Sort (cost=10173466.74..10248673.41 rows=30082670 width=39) (actual time=77051.588..77051.615 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=1537662 read=888872 dirtied=1078 written=7 -> Hash Join (cost=2891105.36..5614260.23 rows=30082670 width=39) (actual time=56552.120..77050.325 rows=525 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1537650 read=888872 dirtied=1078 written=7 -> Seq Scan on lineitem (cost=0.00..1670261.41 rows=60165341 width=8) (actual time=0.040..10189.823 rows=60045379 loops=1) Buffers: shared hit=505249 read=563359 written=3 -> Hash (cost=2797074.41..2797074.41 rows=7522476 width=39) (actual time=56438.314..56438.314 rows=75 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=1032401 read=325513 dirtied=1078 written=4 -> Hash Join (cost=2182624.50..2797074.41 rows=7522476 width=39) (actual time=50407.780..56437.850 rows=75 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=1032401 read=325513 dirtied=1078 written=4 -> Hash Join (cost=2113596.50..2615209.27 rows=7522476 width=20) (actual time=49270.390..55297.653 rows=75 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=1032399 read=290237 dirtied=1078 written=4 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=16) (actual time=0.007..2551.885 rows=15015000 loops=1) Buffers: shared hit=244324 read=9704 dirtied=17 written=1 -> Hash (cost=2062700.65..2062700.65 rows=4071668 width=4) (actual time=49137.232..49137.232 rows=75 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=788075 read=280533 dirtied=1061 written=3 -> HashAggregate (cost=1971088.12..2021983.97 rows=4071668 width=8) (actual time=40009.149..49136.499 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=788075 read=280533 dirtied=1061 written=3 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1670261.41 rows=60165341 width=8) (actual time=0.013..12013.563 rows=60045379 loops=1) Buffers: shared hit=788075 read=280533 dirtied=1061 written=3 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1120.532..1120.532 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=2 read=35276 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.026..671.051 rows=1500000 loops=1) Buffers: shared hit=2 read=35276 Planning time: 3.978 ms Execution time: 77288.620 ms (42 rows) COMMIT; COMMIT