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=10182043.94..10182046.69 rows=100 width=39) (actual time=99266.556..99266.792 rows=75 loops=1) Buffers: shared hit=1272263 read=1156640 dirtied=784 written=5525 -> GroupAggregate (cost=10182043.94..11010136.78 rows=30112467 width=39) (actual time=99266.553..99266.775 rows=75 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1272263 read=1156640 dirtied=784 written=5525 -> Sort (cost=10182043.94..10257325.11 rows=30112467 width=39) (actual time=99266.537..99266.566 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=1272263 read=1156640 dirtied=784 written=5525 -> Hash Join (cost=2892254.05..5618105.73 rows=30112467 width=39) (actual time=79156.916..99265.430 rows=525 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1272251 read=1156640 dirtied=784 written=5525 -> Seq Scan on lineitem (cost=0.00..1671915.34 rows=60224934 width=8) (actual time=0.035..11160.952 rows=60045303 loops=1) Buffers: shared hit=577510 read=492156 -> Hash (cost=2798129.45..2798129.45 rows=7529968 width=39) (actual time=78967.847..78967.847 rows=75 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=694741 read=664484 dirtied=784 written=5525 -> Hash Join (cost=2183434.41..2798129.45 rows=7529968 width=39) (actual time=69714.946..78967.252 rows=75 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=694741 read=664484 dirtied=784 written=5525 -> Hash Join (cost=2114406.41..2616151.93 rows=7529968 width=20) (actual time=66944.061..76189.628 rows=75 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=660488 read=663459 dirtied=784 written=5525 -> Seq Scan on orders (cost=0.00..404880.36 rows=15059936 width=16) (actual time=0.010..3721.542 rows=15015000 loops=1) Buffers: shared hit=152830 read=101451 dirtied=118 written=4908 -> Hash (cost=2063918.41..2063918.41 rows=4039040 width=4) (actual time=66721.306..66721.306 rows=75 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=507658 read=562008 dirtied=666 written=617 -> HashAggregate (cost=1973040.01..2023528.01 rows=4039040 width=8) (actual time=56744.961..66718.308 rows=75 loops=1) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > 315::double precision) Rows Removed by Filter: 15014925 Buffers: shared hit=507658 read=562008 dirtied=666 written=617 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1671915.34 rows=60224934 width=8) (actual time=0.030..13780.374 rows=60045303 loops=1) Buffers: shared hit=507658 read=562008 dirtied=666 written=617 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1144.120..1144.120 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=34253 read=1025 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.030..573.225 rows=1500000 loops=1) Buffers: shared hit=34253 read=1025 Planning time: 4.324 ms Execution time: 99610.645 ms (42 rows) COMMIT; COMMIT