| From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
|---|---|
| To: | PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org> |
| Subject: | patch: plpgsql - remove unnecessary ccache search when a array variable is updated |
| Date: | 2011-06-20 09:49:05 |
| Message-ID: | BANLkTik4Cms2TFM5_V9ADNatTo0efVwi1A@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-hackers |
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.
| Attachment | Content-Type | Size |
|---|---|---|
| array_update.diff | text/x-patch | 5.0 KB |
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Vlad Arkhipov | 2011-06-20 09:54:59 | date_part for infinity intervals |
| Previous Message | Dan Ports | 2011-06-20 09:15:29 | Re: pika buildfarm member failure on isolationCheck tests |