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=10183638.74..10183641.49 rows=100 width=39) (actual time=95144.018..95144.353 rows=100 loops=1) Buffers: shared hit=1521796 read=907107 dirtied=91 written=1467 -> GroupAggregate (cost=10183638.74..11011738.76 rows=30112728 width=39) (actual time=95144.015..95144.342 rows=100 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1521796 read=907107 dirtied=91 written=1467 -> Sort (cost=10183638.74..10258920.56 rows=30112728 width=39) (actual time=95143.991..95144.030 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=1521796 read=907107 dirtied=91 written=1467 -> Hash Join (cost=2893793.19..5619659.23 rows=30112728 width=39) (actual time=71279.222..95142.475 rows=777 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1521784 read=907107 dirtied=91 written=1467 -> Seq Scan on lineitem (cost=0.00..1671920.56 rows=60225456 width=8) (actual time=0.025..12697.970 rows=60045303 loops=1) Buffers: shared hit=698534 read=371132 written=4 -> Hash (cost=2799668.59..2799668.59 rows=7529968 width=39) (actual time=71079.672..71079.672 rows=111 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65544kB Buffers: shared hit=823250 read=535975 dirtied=91 written=1463 -> Hash Join (cost=2184633.26..2799668.59 rows=7529968 width=39) (actual time=62121.644..71079.196 rows=111 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=823250 read=535975 dirtied=91 written=1463 -> Hash Join (cost=2115605.26..2617691.07 rows=7529968 width=20) (actual time=60603.587..69557.392 rows=111 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=823247 read=500700 dirtied=91 written=1463 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=16) (actual time=0.010..3636.669 rows=15015000 loops=1) Buffers: shared hit=199621 read=54660 dirtied=91 written=1460 -> Hash (cost=2064691.89..2064691.89 rows=4073069 width=4) (actual time=60378.017..60378.017 rows=111 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32772kB Buffers: shared hit=623626 read=446040 written=3 -> HashAggregate (cost=1973047.84..2023961.20 rows=4073069 width=8) (actual time=51038.629..60377.314 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=623626 read=446040 written=3 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1671920.56 rows=60225456 width=8) (actual time=0.014..14731.936 rows=60045303 loops=1) Buffers: shared hit=623626 read=446040 written=3 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1494.190..1494.190 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=3 read=35275 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.020..811.865 rows=1500000 loops=1) Buffers: shared hit=3 read=35275 Planning time: 4.681 ms Execution time: 95465.456 ms (42 rows) COMMIT; COMMIT