<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=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-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.EmailStyle17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;}
@page Section1
{size:612.0pt 792.0pt;
margin:70.85pt 70.85pt 70.85pt 70.85pt;}
div.Section1
{page:Section1;}
-->
</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-BE link=blue vlink=purple>
<div class=Section1>
<p class=MsoNormal>Hello,<o:p></o:p></p>
<p class=MsoNormal><o:p> </o:p></p>
<p class=MsoNormal><span lang=EN-US>I have a big shape file to process (about
300 Mo, 1.5 million records)<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>I have to aggregate the touching linestrings
having the same attributes therefore the best way I could find (with help of
this mailing list) was to aggregate all the linestrings with the same attribute
and then splitting the ones that don’t touch.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Here is the query :<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>SELECT subQ.id, subQ.feattyp, subQ.frc,
subQ.shieldnum, subQ.name, null, (st_dump(merged_geom)).geom AS the_geom<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>FROM (<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> SELECT
MAX(id) AS id, feattyp, frc, MAX(shieldnum) AS shieldnum, nw.name,
ST_LineMerge(ST_Collect(the_geom)) AS merged_geom<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> FROM
nw<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> WHERE
nw.frc >= 0<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US> GROUP
BY nw.name, nw.feattyp, nw.frc<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>) AS subQ;<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>This has worked fine on smaller shapes but
on this one I get an out of memory error.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>I used pgTune to change database default settings
and the result is as follow :<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>#custom_variable_classes = '' #
list of custom variable class names<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>default_statistics_target = 50 # pgtune
wizard 2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>maintenance_work_mem = 120MB # pgtune
wizard 2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>constraint_exclusion = on # pgtune wizard
2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>effective_cache_size = 1408MB # pgtune
wizard 2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>work_mem = 12MB # pgtune wizard 2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>wal_buffers = 8MB # pgtune wizard
2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>checkpoint_segments = 16 # pgtune wizard
2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>shared_buffers = 480MB # pgtune wizard
2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US>max_connections = 80 # pgtune wizard
2010-01-13<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>All the other parameters have their default
values.<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>What can I do to run my script through this
heavy shape files ?<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Thank you<o:p></o:p></span></p>
<p class=MsoNormal><span lang=EN-US><o:p> </o:p></span></p>
<p class=MsoNormal><span lang=EN-US>Nicolas.<o:p></o:p></span></p>
</div>
</body>
</html>