gpadmin=# explain select * from prt, (select (random()*100)::int
x from generate_series(1,100))r2 where prt.i=r2.x;
QUERY PLAN
---------------------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=0.00..431.06 rows=1 width=8)
-> Hash Join (cost=0.00..431.06 rows=1 width=8)
Hash Cond: ((int4((random() * '100'::double precision))) = prt.i)
-> Result (cost=0.00..0.00 rows=334 width=1)
One-Time Filter: (gp_execution_segment() = 2)
-> Function Scan on generate_series (cost=0.00..0.00 rows=334 width=1)
-> Hash (cost=431.00..431.00 rows=1 width=4)
-> Broadcast Motion 3:3 (slice2; segments: 3) (cost=0.00..431.00 rows=1 width=4)
-> Seq Scan on prt (cost=0.00..431.00 rows=1 width=4)
Optimizer: Pivotal Optimizer (GPORCA)
(10 rows)
gpadmin=# set optimizer=off;
SET
gpadmin=# explain select * from prt, (select (random()*100)::int x from generate_series(1,100))r2 where prt.i=r2.x;
QUERY PLAN
-----------------------------------------------------------------------------------------
Gather Motion 3:1 (slice1; segments: 3) (cost=40.00..16270.25 rows=96300 width=8)
-> Hash Join (cost=40.00..14344.25 rows=32100 width=8)
Hash Cond: (prt.i = (((random() * '100'::double precision))::integer))
-> Seq Scan on prt (cost=0.00..1063.00 rows=32100 width=4)
-> Hash (cost=27.50..27.50 rows=334 width=4)
-> Function Scan on generate_series (cost=0.00..17.50 rows=334 width=4)
Optimizer: Postgres query optimizer