<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">2017-01-09 12:21 GMT-02:00 RĂ©mi Cura <span dir="ltr"><<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="gmail_default" style="font-family:monospace,monospace">postgres 9.4 is non-parallelised, what you see is that postgres use 100% of a core, but the core beig used is rotated,<br></div><div class="gmail_default" style="font-family:monospace,monospace">which mean the average usage of your cpu is 100% / 4 (your number of core),<br></div><div class="gmail_default" style="font-family:monospace,monospace">which might be the explaination for your 30%.</div></blockquote></div><br>Exactly! I was write something like this.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Please, try the query:</div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">FOR row in</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>SELECT DISTINCT ON (t_x.code, t_y.code)</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>t_x.code,</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>t_y.code,</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ST_Distance(t_x.geom, t_y.geom)</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>FROM t_x, t_y</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ORDER BY t_x.code,</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>t_y.code,</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>ST_Distance(t_x.geom, t_y.geom)</div><div class="gmail_extra">LOOP</div><div class="gmail_extra"><span class="gmail-Apple-tab-span" style="white-space:pre"> </span>-- Do something here</div><div class="gmail_extra">END LOOP;</div></div><div class="gmail_extra"><br>The query above use less conversions, may be more efficient.<br clear="all"><div><br></div><div><br></div>
</div></div>