3 ms·
And if you make a function with with a volatility level of stable it does a One-Time Filter. So you will either get 0 or 1000000 create function random2() re
by minkzilla 3y ago
And if you make a function with with a volatility level of stable it does a One-Time Filter. So you will either get 0 or 1000000
create function random2() returns float as $$
begin
return random();
end;
$$ language plpgsql stable;
select count(*) from one_thousand join one_thousand b on random2() > 0.5;
Query Plan
Aggregate (cost=97615.13..97615.14 rows=1 width=8) (actual time=0.028..0.029 rows=1 loops=1)
-> Result (cost=0.25..81358.88 rows=6502500 width=0) (actual time=0.026..0.027 rows=0 loops=1)
One-Time Filter: (random3() > '0.5'::double precision)
-> Nested Loop (cost=0.25..81358.88 rows=6502500 width=0) (never executed)
-> Seq Scan on one_thousand (cost=0.00..35.50 rows=2550 width=0) (never executed)
-> Materialize (cost=0.00..48.25 rows=2550 width=0) (never executed)
-> Seq Scan on one_thousand b (cost=0.00..35.50 rows=2550 width=0) (never executed)