From: Aleksej Trofimov <aleksej.trofimov@ruptela.lt>
To: pgsql-performance@postgresql.org
Subject: Postgres array parser
Date: Tue, 13 Dec 2011 15:55:02 +0200
Message-ID: <4EE75936.8040806@ruptela.lt> (raw)
Hello, I wanted to ask according such a problem which we had faced with.
We are widely using postgres arrays like key->value array by doing like
this:
{{1,5},{2,6},{3,7}}
where 1,2,3 are keys, and 5,6,7 are values. In our pgSql functions we
are using self written array_input(array::numeric[], key::numeric)
function which makes a loop on whole array and searches for key like
FOR i IN 1 .. size LOOP
if array[i][1] = key then
return array[i][2];
end if;
END LOOP;
But this was a good solution until our arrays and database had grown. So
now FOR loop takes a lot of time to find value of an array.
And my question is, how this problem of performance could be solved? We
had tried pgperl for string parsing, but it takes much more time than
our current solution. Also we are thinking about self-written C++
function, may be someone had implemented this algorithm before?
--
Best regards
Aleksej Trofimov
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 using the --to and --cc options:
reply via email
To: pgsql-performance@postgresql.org
Cc: aleksej.trofimov@ruptela.lt
Subject: Re: Postgres array parser
In-Reply-To: <4EE75936.8040806@ruptela.lt>
* 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