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=10226846.98..10226849.73 rows=100 width=39) (actual time=73970.946..73971.204 rows=84 loops=1) Buffers: shared hit=1575375 read=863046 written=84 -> GroupAggregate (cost=10226846.98..11058238.97 rows=30232436 width=39) (actual time=73970.942..73971.188 rows=84 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1575375 read=863046 written=84 -> Sort (cost=10226846.98..10302428.07 rows=30232436 width=39) (actual time=73970.927..73970.964 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=1575375 read=863046 written=84 -> Hash Join (cost=2907157.70..5643859.70 rows=30232436 width=39) (actual time=55251.330..73969.724 rows=588 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1575363 read=863046 written=84 -> Seq Scan on lineitem (cost=0.00..1678566.72 rows=60464872 width=8) (actual time=0.022..10114.288 rows=60044664 loops=1) Buffers: shared hit=680561 read=393357 -> Hash (cost=2812657.75..2812657.75 rows=7559996 width=39) (actual time=54669.696..54669.696 rows=84 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=894802 read=469689 written=84 -> Hash Join (cost=2194697.63..2812657.75 rows=7559996 width=39) (actual time=49072.225..54669.518 rows=84 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=894802 read=469689 written=84 -> Hash Join (cost=2125669.63..2630229.81 rows=7559996 width=20) (actual time=48004.447..53601.496 rows=84 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=881983 read=447230 written=6 -> Seq Scan on orders (cost=0.00..406494.91 rows=15119991 width=16) (actual time=0.009..2695.450 rows=15015000 loops=1) Buffers: shared hit=255295 -> Hash (cost=2073963.00..2073963.00 rows=4136530 width=4) (actual time=47887.083..47887.083 rows=84 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=626688 read=447230 written=6 -> HashAggregate (cost=1980891.08..2032597.70 rows=4136530 width=8) (actual time=40286.365..47886.441 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=626688 read=447230 written=6 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1678566.72 rows=60464872 width=8) (actual time=0.012..12186.704 rows=60044664 loops=1) Buffers: shared hit=626688 read=447230 written=6 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1052.263..1052.263 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=12819 read=22459 written=78 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.015..582.147 rows=1500000 loops=1) Buffers: shared hit=12819 read=22459 written=78 Planning time: 3.788 ms Execution time: 74204.337 ms (42 rows) COMMIT; COMMIT