Thread
-
patch: plpgsql - remove unnecessary ccache search when a array variable is updated
Pavel Stehule <pavel.stehule@gmail.com> — 2011-06-20T09:49:05Z
Hello this patch significantly reduce a ccache searching. On my test - bubble sort postgres=# \sf buble CREATE OR REPLACE FUNCTION public.buble(integer[]) RETURNS integer[] LANGUAGE plpgsql AS $function$ declare unsorted bool := true; aux int; begin while unsorted loop unsorted := false; for i in array_lower($1,1) .. array_upper($1,1) - 1 loop if $1[i] > $1[i+1] then aux := $1[i]; $1[i] := $1[i+1]; $1[i+1] := aux; unsorted := true; end if; end loop; end loop; return $1; end; $function$ immutable it decrease evaluation time about 15%. Regards Pavel Stehule p.s. I know so bubble sort is not effective for large arrays. This algorithm was used because a array is intensive modified.