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) > 313 ) 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=105107.584..105107.899 rows=99 loops=1) Buffers: shared hit=1380712 read=1048191 written=13 -> GroupAggregate (cost=10183638.74..11011738.76 rows=30112728 width=39) (actual time=105107.580..105107.886 rows=99 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1380712 read=1048191 written=13 -> Sort (cost=10183638.74..10258920.56 rows=30112728 width=39) (actual time=105107.531..105107.572 rows=693 loops=1) Sort Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Sort Method: quicksort Memory: 79kB Buffers: shared hit=1380712 read=1048191 written=13 -> Hash Join (cost=2893793.19..5619659.23 rows=30112728 width=39) (actual time=80900.405..105106.020 rows=693 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1380700 read=1048191 written=13 -> Seq Scan on lineitem (cost=0.00..1671920.56 rows=60225456 width=8) (actual time=0.025..12709.438 rows=60045303 loops=1) Buffers: shared hit=574631 read=495035 written=2 -> Hash (cost=2799668.59..2799668.59 rows=7529968 width=39) (actual time=80373.246..80373.246 rows=99 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65543kB Buffers: shared hit=806069 read=553156 written=11 -> Hash Join (cost=2184633.26..2799668.59 rows=7529968 width=39) (actual time=70625.711..80369.435 rows=99 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=806069 read=553156 written=11 -> Hash Join (cost=2115605.26..2617691.07 rows=7529968 width=20) (actual time=69348.455..79086.830 rows=99 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=806062 read=517885 written=11 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=16) (actual time=0.010..3894.460 rows=15015000 loops=1) Buffers: shared hit=164798 read=89483 written=6 -> Hash (cost=2064691.89..2064691.89 rows=4073069 width=4) (actual time=68865.893..68865.893 rows=99 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32772kB Buffers: shared hit=641264 read=428402 written=5 -> HashAggregate (cost=1973047.84..2023961.20 rows=4073069 width=8) (actual time=57064.111..68862.330 rows=99 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 313::double precision) Rows Removed by Filter: 15014901 Buffers: shared hit=641264 read=428402 written=5 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1671920.56 rows=60225456 width=8) (actual time=0.016..14448.158 rows=60045303 loops=1) Buffers: shared hit=641264 read=428402 written=5 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1264.674..1264.674 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=7 read=35271 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.017..764.530 rows=1500000 loops=1) Buffers: shared hit=7 read=35271 Planning time: 4.573 ms Execution time: 105422.171 ms (42 rows) COMMIT; COMMIT