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=10174948.58..10174951.33 rows=100 width=39) (actual time=104561.614..104561.886 rows=84 loops=1) Buffers: shared hit=1429906 read=996628 dirtied=1 written=4 -> GroupAggregate (cost=10174948.58..11002225.34 rows=30082791 width=39) (actual time=104561.611..104561.872 rows=84 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1429906 read=996628 dirtied=1 written=4 -> Sort (cost=10174948.58..10250155.56 rows=30082791 width=39) (actual time=104561.595..104561.634 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=1429906 read=996628 dirtied=1 written=4 -> Hash Join (cost=2892561.17..5615722.67 rows=30082791 width=39) (actual time=81084.996..104560.492 rows=588 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1429894 read=996628 dirtied=1 written=4 -> Seq Scan on lineitem (cost=0.00..1670263.82 rows=60165582 width=8) (actual time=0.044..12833.497 rows=60045379 loops=1) Buffers: shared hit=555537 read=513071 written=1 -> Hash (cost=2798530.21..2798530.21 rows=7522476 width=39) (actual time=80818.345..80818.345 rows=84 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=874357 read=483557 dirtied=1 written=3 -> Hash Join (cost=2183757.59..2798530.21 rows=7522476 width=39) (actual time=71514.745..80817.900 rows=84 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=874357 read=483557 dirtied=1 written=3 -> Hash Join (cost=2114729.59..2616665.07 rows=7522476 width=20) (actual time=69999.022..79296.737 rows=84 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=874310 read=448326 dirtied=1 written=3 -> Seq Scan on orders (cost=0.00..404477.52 rows=15044952 width=16) (actual time=0.010..3742.945 rows=15015000 loops=1) Buffers: shared hit=243208 read=10820 -> Hash (cost=2063430.36..2063430.36 rows=4103939 width=4) (actual time=69812.868..69812.868 rows=84 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=631102 read=437506 dirtied=1 written=3 -> HashAggregate (cost=1971091.73..2022390.97 rows=4103939 width=8) (actual time=58352.342..69812.235 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=631102 read=437506 dirtied=1 written=3 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1670263.82 rows=60165582 width=8) (actual time=0.010..15504.151 rows=60045379 loops=1) Buffers: shared hit=631102 read=437506 dirtied=1 written=3 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1500.107..1500.107 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=47 read=35231 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.029..894.010 rows=1500000 loops=1) Buffers: shared hit=47 read=35231 Planning time: 5.633 ms Execution time: 104758.845 ms (42 rows) COMMIT; COMMIT