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) > 315 ) 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=10236890.77..10236893.52 rows=100 width=39) (actual time=77439.901..77440.131 rows=75 loops=1) Buffers: shared hit=1379431 read=1061359 written=133 -> GroupAggregate (cost=10236890.77..11069101.82 rows=30262220 width=39) (actual time=77439.898..77440.120 rows=75 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1379431 read=1061359 written=133 -> Sort (cost=10236890.77..10312546.32 rows=30262220 width=39) (actual time=77439.877..77439.914 rows=525 loops=1) Sort Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Sort Method: quicksort Memory: 66kB Buffers: shared hit=1379431 read=1061359 written=133 -> Hash Join (cost=2909774.29..5649172.43 rows=30262220 width=39) (actual time=57918.157..77438.951 rows=525 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1379419 read=1061359 written=133 -> Seq Scan on lineitem (cost=0.00..1680220.41 rows=60524441 width=8) (actual time=0.028..10522.524 rows=59983922 loops=1) Buffers: shared hit=716924 read=358052 -> Hash (cost=2815180.69..2815180.69 rows=7567488 width=39) (actual time=57831.193..57831.193 rows=75 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=662495 read=703307 written=133 -> Hash Join (cost=2196649.17..2815180.69 rows=7567488 width=39) (actual time=49305.704..57830.958 rows=75 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=662495 read=703307 written=133 -> Hash Join (cost=2127621.17..2632640.37 rows=7567488 width=20) (actual time=48305.499..56830.510 rows=75 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=627322 read=703202 written=133 -> Seq Scan on orders (cost=0.00..406897.75 rows=15134975 width=16) (actual time=0.009..3549.970 rows=15000000 loops=1) Buffers: shared hit=95934 read=159614 written=133 -> Hash (cost=2075914.54..2075914.54 rows=4136530 width=4) (actual time=48175.210..48175.210 rows=75 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=531388 read=543588 -> HashAggregate (cost=1982842.62..2034549.24 rows=4136530 width=8) (actual time=40131.032..48174.863 rows=75 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 315::double precision) Rows Removed by Filter: 14999925 Buffers: shared hit=531388 read=543588 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1680220.41 rows=60524441 width=8) (actual time=0.011..11954.568 rows=59983922 loops=1) Buffers: shared hit=531388 read=543588 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=989.212..989.212 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=35173 read=105 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.016..483.693 rows=1500000 loops=1) Buffers: shared hit=35173 read=105 Planning time: 3.859 ms Execution time: 77602.297 ms (42 rows) COMMIT; COMMIT