<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta http-equiv=Content-Type content="text/html; charset=utf-8"><meta name=Generator content="Microsoft Word 12 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:Verdana;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.gmail-apple-tab-span
        {mso-style-name:gmail-apple-tab-span;}
span.EmailStyle18
        {mso-style-type:personal-reply;
        font-family:"Verdana","sans-serif";
        font-variant:normal !important;
        color:#1F497D;
        text-transform:none;
        text-shadow:none;
        font-weight:normal;
        font-style:normal;
        text-decoration:none none;
        vertical-align:baseline;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]--></head><body lang=FR link=blue vlink=purple><div class=WordSection1><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D'>Well, thanks, could be the explanation.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D'><o:p> </o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D'>I tried the query but I get SQLSTATE 53200, out of memory after a few seconds.<o:p></o:p></span></p><p class=MsoNormal><span lang=EN-US style='font-size:10.0pt;font-family:"Verdana","sans-serif";color:#1F497D'><o:p> </o:p></span></p><div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0cm 0cm 0cm'><p class=MsoNormal><b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'>De :</span></b><span style='font-size:10.0pt;font-family:"Tahoma","sans-serif"'> postgis-users [mailto:postgis-users-bounces@lists.osgeo.org] <b>De la part de</b> Marcone<br><b>Envoyé :</b> lundi 9 janvier 2017 15:31<br><b>À :</b> PostGIS Users Discussion<br><b>Objet :</b> Re: [postgis-users] CPU tuning<o:p></o:p></span></p></div><p class=MsoNormal><o:p> </o:p></p><div><div><p class=MsoNormal><o:p> </o:p></p><div><p class=MsoNormal>2017-01-09 12:21 GMT-02:00 Rémi Cura <<a href="mailto:remi.cura@gmail.com" target="_blank">remi.cura@gmail.com</a>>:<o:p></o:p></p><div><p class=MsoNormal><span style='font-family:"Courier New"'>postgres 9.4 is non-parallelised, what you see is that postgres use 100% of a core, but the core beig used is rotated,<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>which mean the average usage of your cpu is 100% / 4 (your number of core),<o:p></o:p></span></p></div><div><p class=MsoNormal><span style='font-family:"Courier New"'>which might be the explaination for your 30%.<o:p></o:p></span></p></div></div><p class=MsoNormal><br>Exactly! I was write something like this.<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal>Please, try the query:<o:p></o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div><div><div><p class=MsoNormal>FOR row in<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>            </span>SELECT DISTINCT ON (t_x.code, t_y.code)<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>                        </span>t_x.code,<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>                        </span>t_y.code,<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>                        </span>ST_Distance(t_x.geom, t_y.geom)<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>            </span>FROM t_x, t_y<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>            </span>ORDER BY t_x.code,<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>                        </span>t_y.code,<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>                        </span>ST_Distance(t_x.geom, t_y.geom)<o:p></o:p></p></div><div><p class=MsoNormal>LOOP<o:p></o:p></p></div><div><p class=MsoNormal><span class=gmail-apple-tab-span>            </span>-- Do something here<o:p></o:p></p></div><div><p class=MsoNormal>END LOOP;<o:p></o:p></p></div></div><div><p class=MsoNormal><br>The query above use less conversions, may be more efficient.<br clear=all><o:p></o:p></p><div><p class=MsoNormal><o:p> </o:p></p></div><div><p class=MsoNormal><o:p> </o:p></p></div></div></div></div>
<br /><br />
<hr style='border:none; color:#909090; background-color:#B0B0B0; height: 1px; width: 99%;' />
<table style='border-collapse:collapse;border:none;'>
        <tr>
                <td style='border:none;padding:0px 15px 0px 8px'>
                        <a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient">
                                <img border=0 src="http://static.avast.com/emails/avast-mail-stamp.png" alt="Avast logo" />
                        </a>
                </td>
                <td>
                        <p style='color:#3d4d5a; font-family:"Calibri","Verdana","Arial","Helvetica"; font-size:12pt;'>
                                L'absence de virus dans ce courrier électronique a été vérifiée par le logiciel antivirus Avast.
                                <br><a href="https://www.avast.com/sig-email?utm_medium=email&utm_source=link&utm_campaign=sig-email&utm_content=emailclient">www.avast.com</a>
                        </p>
                </td>
        </tr>
</table>
<br />
</body></html>