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=10176456.99..10176459.74 rows=100 width=39) (actual time=81977.828..81978.130 rows=100 loops=1) Buffers: shared hit=1419305 read=1007229 dirtied=688 written=614 -> GroupAggregate (cost=10176456.99..11003738.17 rows=30082952 width=39) (actual time=81977.825..81978.120 rows=100 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1419305 read=1007229 dirtied=688 written=614 -> Sort (cost=10176456.99..10251664.37 rows=30082952 width=39) (actual time=81977.804..81977.848 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=1419305 read=1007229 dirtied=688 written=614 -> Hash Join (cost=2894032.58..5617202.91 rows=30082952 width=39) (actual time=62617.491..81976.093 rows=777 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1419293 read=1007229 dirtied=688 written=614 -> Seq Scan on lineitem (cost=0.00..1670267.03 rows=60165903 width=8) (actual time=0.027..10850.700 rows=60045379 loops=1) Buffers: shared hit=593760 read=474848 dirtied=502 written=502 -> Hash (cost=2800001.63..2800001.63 rows=7522476 width=39) (actual time=62247.899..62247.899 rows=111 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65544kB Buffers: shared hit=825533 read=532381 dirtied=186 written=112 -> Hash Join (cost=2184903.10..2800001.63 rows=7522476 width=39) (actual time=54236.014..62247.350 rows=111 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=825533 read=532381 dirtied=186 written=112 -> Hash Join (cost=2115875.10..2618136.49 rows=7522476 width=20) (actual time=52920.164..60925.864 rows=111 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=825531 read=497105 dirtied=186 written=3 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=16) (actual time=0.006..3042.694 rows=15015000 loops=1) Buffers: shared hit=186084 read=67944 dirtied=183 written=3 -> Hash (cost=2064168.47..2064168.47 rows=4136530 width=4) (actual time=52719.060..52719.060 rows=111 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32772kB Buffers: shared hit=639447 read=429161 dirtied=3 -> HashAggregate (cost=1971096.55..2022803.17 rows=4136530 width=8) (actual time=40933.661..52717.860 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=639447 read=429161 dirtied=3 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1670267.03 rows=60165903 width=8) (actual time=0.012..12444.359 rows=60045379 loops=1) Buffers: shared hit=639447 read=429161 dirtied=3 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1297.568..1297.568 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=2 read=35276 written=109 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.013..701.220 rows=1500000 loops=1) Buffers: shared hit=2 read=35276 written=109 Planning time: 4.194 ms Execution time: 82319.881 ms (42 rows) COMMIT; COMMIT