<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
</head>
<body text="#000000" bgcolor="#FFFFFF">
Dear all,<br>
<br>
<span id="result_box" class="" lang="en"><span class="hps">I'm
writing a</span> <span class="hps">stored procedure</span> (</span><span
id="result_box" class="" lang="en"><span class="hps">pgplSQL) </span></span><span
id="result_box" class="" lang="en"><span class="hps">that uses</span>
<span class="hps"></span></span><span id="result_box" class=""
lang="en"><span class="hps"><span id="result_box" class=""
lang="en"><span class="hps">postgis</span> <span class="hps"></span></span>functions</span>
<span class="hps">version 2.1</span><br>
<span class="hps">Dump</span> <span class="hps">the contents of</span>
<span class="hps">an image on a</span> <span class="hps">two</span><span
class="atn">-</span><span>dimensional</span> <span class="hps">array</span>
<span class="hps">and then I</span> <span class="hps">update</span>
<span class="hps">the cells</span> <span class="hps">according to</span>
<span class="hps">some calculations</span><span>.</span><br>
<span class="hps">The process</span> <span class="hps">is slow</span><span>,</span>
<span class="hps">but after</span> <span class="hps">a while</span>
<span class="hps">I discovered</span> <span class="hps">devote</span>
<span class="hps">to</span> <span class="hps">the problem, or</span>
<span class="hps">the slowness</span> <span class="hps">is due to</span>
<span class="hps">operations</span> <span class="hps">that read
and</span> <span class="hps">update the</span> <span
class="hps">two</span><span class="atn">-</span><span>dimensional</span>
<span class="hps">array</span><span>.</span><br>
<br>
<span class="hps">The code</span> <span class="hps">is roughly</span>
<span class="hps">this</span><span>:</span><br>
<br>
<span class="hps">DECLARE</span><br>
<span class="hps">..</span><br>
<b><span class="hps">img</span></b><b> </b><span class="hps">double
precision</span> <span class="hps atn">[</span><span>]</span> <span
class="hps atn">[</span><span>]</span><span>;</span><br>
<br>
<span class="hps">i</span> <span class="hps">integer</span> <span
class="hps">j</span> <span class="hps">integer;</span><br>
<br>
<span class="hps">BEGIN</span><br>
<br>
<span class="hps">select</span> <span class="hps">ST_DumpValues</span>
<span class="hps atn">(</span><span>rast</span><span>, 1,</span>
<span class="hps">false)</span> <span class="hps">INTO</span> <b><span
class="hps">img</span></b><b> </b><span class="hps">from ..</span><br>
<br>
<span class="hps">for i</span> <span class="hps">IN 1</span>
<span class="hps">.. 1000</span> <span class="hps">LOOP</span><br>
<span class="hps">for j</span> <span class="hps">IN 1</span>
<span class="hps">..</span> <span class="hps">500</span> <span
class="hps">LOOP</span><br>
<span class="hps">........</span><br>
<b><span class="hps">img</span></b><b> </b><span
class="hps atn">[</span><span>i</span><span>]</span> <span
class="hps atn">[</span><span>j</span><span>]</span><span>:</span>
<span class="hps">=</span> <span class="hps">..............</span><span>;</span><br>
<span class="hps">END</span> <span class="hps">LOOP</span><span>;</span><br>
<span class="hps">END</span> <span class="hps">LOOP</span><span>;</span><br>
<br>
<span class="hps">select</span> <span class="hps">ST_SetValues</span>
<span class="hps">(image,</span> <span class="hps">1, 1</span><span>,
1,</span> <b><span class="hps">img</span></b><span>)</span> <span
class="hps">INTO</span> <span class="hps">imagen2</span><span>;</span><br>
<span class="hps">....</span><br>
<span class="hps">END;</span><br>
<br>
<span class="hps">Anyone know</span> <span class="hps">why</span>
<span class="hps">the update</span> <span class="hps">of the
values</span> <span class="hps">of the</span> <span
class="hps">two</span><span class="atn">-</span><span>dimensional</span>
<span class="hps">array</span> <span class="hps">is slow</span><span>?</span><span>,
Poorly</span> <span class="hps">defined</span> <span
class="hps">array</span> <span class="hps">for the</span> <span
class="hps">type of operations</span> <span class="hps">performed</span><span>?</span><br>
<br>
<span class="hps">thank you very much<br>
Best regards.<br>
<br>
</span></span>Miguel A. Manso<br>
</body>
</html>