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=10210250.91..10210253.66 rows=100 width=39) (actual time=97261.353..97261.626 rows=84 loops=1) Buffers: shared hit=1417302 read=1018741 dirtied=109 written=2523 -> GroupAggregate (cost=10210250.91..11040819.08 rows=30202479 width=39) (actual time=97261.349..97261.613 rows=84 loops=1) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey Buffers: shared hit=1417302 read=1018741 dirtied=109 written=2523 -> Sort (cost=10210250.91..10285757.11 rows=30202479 width=39) (actual time=97261.337..97261.377 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=1417302 read=1018741 dirtied=109 written=2523 -> Hash Join (cost=2898028.36..5632020.71 rows=30202479 width=39) (actual time=74524.451..97260.262 rows=588 loops=1) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) Buffers: shared hit=1417290 read=1018741 dirtied=109 written=2523 -> Seq Scan on lineitem (cost=0.00..1676905.58 rows=60404958 width=8) (actual time=0.032..12377.191 rows=60045310 loops=1) Buffers: shared hit=651306 read=421550 written=5 -> Hash (cost=2803622.44..2803622.44 rows=7552474 width=39) (actual time=74164.173..74164.173 rows=84 loops=1) Buckets: 8388608 Batches: 1 Memory Usage: 65542kB Buffers: shared hit=765984 read=597191 dirtied=109 written=2518 -> Hash Join (cost=2187680.65..2803622.44 rows=7552474 width=39) (actual time=67001.125..74163.650 rows=84 loops=1) Hash Cond: (orders.o_custkey = customer.c_custkey) Buffers: shared hit=765984 read=597191 dirtied=109 written=2518 -> Hash Join (cost=2118652.65..2621307.33 rows=7552474 width=20) (actual time=65783.815..72941.144 rows=84 loops=1) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) Buffers: shared hit=730873 read=597024 dirtied=109 written=2518 -> Seq Scan on orders (cost=0.00..406090.48 rows=15104948 width=16) (actual time=0.011..4043.486 rows=15015000 loops=1) Buffers: shared hit=143372 read=111669 dirtied=109 written=2518 -> Hash (cost=2068751.83..2068751.83 rows=3992065 width=4) (actual time=65623.531..65623.531 rows=84 loops=1) Buckets: 4194304 Batches: 1 Memory Usage: 32771kB Buffers: shared hit=587501 read=485355 -> HashAggregate (cost=1978930.37..2028831.18 rows=3992065 width=8) (actual time=53521.621..65621.319 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=587501 read=485355 -> Seq Scan on lineitem lineitem_1 (cost=0.00..1676905.58 rows=60404958 width=8) (actual time=0.031..13844.284 rows=60045310 loops=1) Buffers: shared hit=587501 read=485355 -> Hash (cost=50278.00..50278.00 rows=1500000 width=23) (actual time=1200.673..1200.673 rows=1500000 loops=1) Buckets: 2097152 Batches: 1 Memory Usage: 98416kB Buffers: shared hit=35111 read=167 -> Seq Scan on customer (cost=0.00..50278.00 rows=1500000 width=23) (actual time=0.019..574.249 rows=1500000 loops=1) Buffers: shared hit=35111 read=167 Planning time: 4.496 ms Execution time: 97501.623 ms (42 rows) COMMIT; COMMIT