On 05/08/14 17:56, Mark Kirkwood wrote:
>
> Adding in the 'if' in the float8 case increases run time to 4s. So looks
> like plpgsql might have a slightly higher cost for handling added
> conditionals. Be interesting to dig a bit more and see what is taking
> the time.
>
Thinking about this a bit more, I wonder if the 'big O' has added some
optimizations in PL/SQL for trivial conditionals - i.e you are adding:
IF (0 = 0) THEN
END IF;
...it may be going...'Ah yes, always true...so remove'!
So it might be interesting to try some (hopefully not so easily
removable) non trivial ones like:
DO LANGUAGE plpgsql $$ DECLARE
DECLARE i integer;
BEGIN
FOR i IN 1..10000000 LOOP IF (i%100 = 0) THEN NULL; END IF;
END LOOP;
END $$;
Now I guess there is the chance that PL/SQL might understand that NULL
inside a loop means it can remove it...so you may need to experiment
further. The point to take away here is that for interesting loops and
conditions - there may be not such a significant difference!
Regards
Mark