2015-05-01 20:53 GMT+02:00 Pavel Stehule <pavel.steh...@gmail.com>: > > > 2015-05-01 20:11 GMT+02:00 Tom Lane <t...@sss.pgh.pa.us>: > >> Pavel Stehule <pavel.steh...@gmail.com> writes: >> > I am looking on this patch, but it cannot be applied now. >> >> > lxml2 -lssl -lcrypto -lrt -lcrypt -ldl -lm -o postgres >> > utils/fmgrtab.o:(.rodata+0x2678): undefined reference to `array_append' >> > utils/fmgrtab.o:(.rodata+0x2698): undefined reference to `array_prepend' >> >> What are you trying to apply it to? I see array_append() in >> src/backend/utils/adt/array_userfuncs.c in HEAD. Also, are >> you checking the 1.1 version of the patch? >> > > I tested old version. 1.1. looks well. >
It is hard to believe how it is fast I use buble sort for plpgsql benchmarking. Following variant is suboptimal (but it is perfect for this test) CREATE OR REPLACE FUNCTION public.buble(a anyarray, OUT r anyarray) RETURNS anyarray LANGUAGE plpgsql AS $function$ DECLARE aux r%type; sorted bool := false; BEGIN r := a; WHILE NOT sorted LOOP sorted := true; FOR i IN array_lower(a,1) .. array_upper(a,1) - 1 LOOP IF r[i] > r[i+1] THEN sorted := false; aux[1] := r[i]; r[i] := r[i+1]; r[i+1] := aux[1]; END IF; END LOOP; END LOOP; END; $function$ CREATE OR REPLACE FUNCTION public.array_generator(integer, anyelement, OUT r anyarray) RETURNS anyarray LANGUAGE plpgsql AS $function$ BEGIN r := (SELECT ARRAY(SELECT random()*$2 FROM generate_series(1,$1))); END; $function$ Test for 3000 elements: Original Patch Integer 55sec 8sec Numeric 341sec 8sec Quicksort is about 3x faster -- so a benefit of this patch is clear. Regards Pavel > > Regards > > Pavel > > >> >> regards, tom lane >> > >