Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VR198-00009i-8a for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Oct 2013 14:41:54 +0000 Received: from localhost ([127.0.0.1] helo=postgresql.org) by malur.postgresql.org with smtp (Exim 4.80) (envelope-from ) id 1VR197-000814-P9 for pgsql-bugs@arkaria.postgresql.org; Tue, 01 Oct 2013 14:41:53 +0000 Received: from makus.postgresql.org ([2001:4800:7903:4::125]) by malur.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQutk-00075T-Dx for pgsql-bugs@postgresql.org; Tue, 01 Oct 2013 08:01:36 +0000 Received: from mahout.postgresql.org ([2001:4800:7903:4::123]) by makus.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQuth-0004Ew-K4 for pgsql-bugs@postgresql.org; Tue, 01 Oct 2013 08:01:35 +0000 Received: from wrigleys.postgresql.org ([204.145.124.246]) by mahout.postgresql.org with esmtp (Exim 4.80) (envelope-from ) id 1VQutg-00073B-84 for pgsql-bugs@postgresql.org; Tue, 01 Oct 2013 08:01:33 +0000 Received: from www-data by wrigleys.postgresql.org with local (Exim 4.80) (envelope-from ) id 1VQuta-0007Y4-Ip for pgsql-bugs@postgresql.org; Tue, 01 Oct 2013 08:01:26 +0000 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays. To: pgsql-bugs@postgresql.org From: m.manso@upm.es Message-Id: Date: Tue, 01 Oct 2013 08:01:26 +0000 X-Pg-Spam-Score: 0.1 (/) List-Archive: List-Help: List-ID: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-Mailing-List: pgsql-bugs Precedence: bulk Sender: pgsql-bugs-owner@postgresql.org The following bug has been logged on the website: Bug reference: 8495 Logged by: Miguel A. Manso Callejo Email address: m.manso@upm.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. -- Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-bugs