pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: m.manso@upm.es
To: pgsql-bugs@postgresql.org
Subject: BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays.
Date: Tue, 01 Oct 2013 08:01:26 +0000
Message-ID: <E1VQuta-0007Y4-Ip@wrigleys.postgresql.org> (raw)
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

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



view thread (2+ messages)  latest in thread

Message-ID: <E1VQuta-0007Y4-Ip@wrigleys.postgresql.org>
Permalink:  ../E1VQuta-0007Y4-Ip@wrigleys.postgresql.org/
Also on:    postgresql.org/message-id/E1VQuta-0007Y4-Ip@wrigleys.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: m.manso@upm.es
  Subject: Re: BUG #8495: PLSQL PG Terrible performance by using two-dimensional arrays.
  In-Reply-To: <E1VQuta-0007Y4-Ip@wrigleys.postgresql.org>
  References: <E1VQuta-0007Y4-Ip@wrigleys.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox