BEGIN; BEGIN EXPLAIN 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=133318713.15..133318762.14 rows=100 width=39) -> GroupAggregate (cost=133318713.15..175875506.10 rows=86875298 width=39) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Remote Subquery Scan on all (datanode_1_1,datanode_2_1,datanode_3_1,datanode_4_1,datanode_5_1,datanode_6_1,datanode_7_1,datanode_8_1) (cost=133318713.15..173703623.65 rows=86875298 width=39) -> GroupAggregate (cost=133318713.15..173703623.65 rows=86875298 width=39) Group Key: orders.o_totalprice, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Sort (cost=187534691.74..187751879.99 rows=86875298 width=39) Sort Key: orders.o_totalprice DESC, orders.o_orderdate, customer.c_name, customer.c_custkey, orders.o_orderkey -> Hash Join (cost=133318713.15..173703623.65 rows=86875298 width=39) Hash Cond: (lineitem.l_orderkey = orders.o_orderkey) -> Seq Scan on lineitem (cost=0.00..16657556.88 rows=600037888 width=8) -> Hash (cost=132877576.99..132877576.99 rows=21717453 width=39) -> Hash Join (cost=122350987.53..132877576.99 rows=21717453 width=39) Hash Cond: (orders.o_custkey = customer.c_custkey) -> Hash Join (cost=121572825.53..129321691.46 rows=75000000 width=20) Hash Cond: (orders.o_orderkey = lineitem_1.l_orderkey) -> Seq Scan on orders (cost=0.00..4032887.00 rows=150000000 width=16) -> Hash (cost=119580615.87..119580615.87 rows=121429893 width=4) -> GroupAggregate (cost=112348159.12..118366316.94 rows=121429893 width=8) Group Key: lineitem_1.l_orderkey Filter: (sum(lineitem_1.l_quantity) > '313'::double precision) -> Sort (cost=112348159.12..113848253.84 rows=600037888 width=8) Sort Key: lineitem_1.l_orderkey -> Seq Scan on lineitem lineitem_1 (cost=0.00..16657556.88 rows=600037888 width=8) -> Hash (cost=502771.00..502771.00 rows=15000000 width=23) -> Seq Scan on customer (cost=0.00..502771.00 rows=15000000 width=23) (26 rows) COMMIT; COMMIT