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) > 314 ) 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=10179982.26..10179985.01 rows=100 width=39) (actual time=101275.840..101276.118 rows=84 loops=1) Buffers: shared hit=1586440 read=842463 written=12 -> GroupAggregate (cost=10179982.26..11008080.85 rows=30112676 width=39) (actual time=101275.835..101276.097 rows=84 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1586440 read=842463 written=12 -> Sort (cost=10179982.26..10255263.95 rows=30112676 width=39) (actual time=101275.815..101275.850 rows=588 loops=1) Sort Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Sort Method: quicksort Memory: 70kB Buffers: shared hit=1586440 read=842463 written=12 -> Hash Join (cost=2890146.43..5616009.59 rows=30112676 width=39) (actual time=77383.651..101274.511 rows=588 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1586428 read=842463 written=12 -> Seq Scan on lineitem (cost=0.00..1671919.51 rows=60225351 width=8) (actual time=0.022..13001.505 rows=60045303 loops=1) Buffers: shared hit=743755 read=325911 written=5 -> Hash (cost=2796021.83..2796021.83 rows=7529968 width=39) (actual time=77314.103..77314.103 rows=84 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=842673 read=516552 written=7 -> Hash Join (cost=2181796.54..2796021.83 rows=7529968 width=39) (actual time=67882.386..77313.435 rows=84 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=842673 read=516552 written=7 -> Hash Join (cost=2112768.54..2614044.31 rows=7529968 width=20) (actual time=66677.023..76102.495 rows=84 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=807534 read=516413 written=7 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=16) (actual time=0.010..3631.532 rows=15015000 loops=1) Buffers: shared hit=219884 read=34397 written=3 -> Hash (cost=2062867.73..2062867.73 rows=3992065 width=4) (actual time=66463.565..66463.565 rows=84 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=587650 read=482016 written=4 -> HashAggregate (cost=1973046.26..2022947.08 rows=3992065 width=8) (actual time=54286.640..66460.237 rows=84 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 314::double precision) Rows Removed by Filter: 15014916 Buffers: shared hit=587650 read=482016 written=4 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1671919.51 rows=60225351 width=8) (actual time=0.015..14602.327 rows=60045303 loops=1) Buffers: shared hit=587650 read=482016 written=4 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1185.631..1185.631 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=35139 read=139 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.021..586.546 rows=1500000 loops=1) Buffers: shared hit=35139 read=139 Planning time: 4.517 ms Execution time: 101544.079 ms (42 rows) COMMIT; COMMIT