BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays.

From: m(dot)manso(at)upm(dot)es
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays.
Date: 2013-10-01 08:01:26
Message-ID: E1VQuta-0007Y4-Ip@wrigleys.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

The following bug has been logged on the website:

Bug reference: 8495
Logged by: Miguel A. Manso Callejo
Email address: m(dot)manso(at)upm(dot)es
PostgreSQL version: 9.1.9
Operating system: Ubuntu 12.04LTS
Description:

I'm trying to random access to a 2-dimensional array of double precision
numbers. When range of the array increase, the performance decrease
quickly.
A simple function as:
CREATE OR REPLACE FUNCTION fill_2d_array( rows integer, cols integer)
RETURNS integer AS
$BODY$
DECLARE
img double precision[][];
i integer; j integer;
cont integer;
BEGIN
img := ARRAY( SELECT 0 FROM generate_series(1, rows * cols) ) ;
cont:= 0;
For i IN 1..rows LOOP
For j IN 1..cols LOOP
img[i * cols + j] := (i * cols + j)::double precision;
cont := cont + 1;
END LOOP;
END LOOP;
return cont;
END;
$BODY$
LANGUAGE plpgsql;
ALTER FUNCTION fill_2d_array( integer, integer)
OWNER TO postgres;

when call the function with 700 rows & 1200 cols (explain (analyze,buffers)
select fill_2d_array(700,1200); ) the time consumed is about 50minutes.

What is bad? what i'm doing bad?

Thank you very much.

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Pavel Stehule 2013-10-01 15:59:41 Re: BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays.
Previous Message ha 2013-10-01 02:17:00 BUG #8494: Cannot Backup / Restore