<p dir="ltr">Kleber 0 e a outra metade da população de São</p>
<div class="gmail_quote">Em 18/07/2013 16:01, <<a href="mailto:postgis-devel-request@lists.osgeo.org">postgis-devel-request@lists.osgeo.org</a>> escreveu:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Send postgis-devel mailing list submissions to<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<br>
To subscribe or unsubscribe via the World Wide Web, visit<br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
or, via email, send a message with subject or body 'help' to<br>
<a href="mailto:postgis-devel-request@lists.osgeo.org">postgis-devel-request@lists.osgeo.org</a><br>
<br>
You can reach the person managing the list at<br>
<a href="mailto:postgis-devel-owner@lists.osgeo.org">postgis-devel-owner@lists.osgeo.org</a><br>
<br>
When replying, please edit your Subject line so it is more specific<br>
than "Re: Contents of postgis-devel digest..."<br>
<br>
<br>
Today's Topics:<br>
<br>
1. Re: creating topology (Sandro Santilli)<br>
<br>
<br>
----------------------------------------------------------------------<br>
<br>
Message: 1<br>
Date: Wed, 17 Jul 2013 22:46:34 +0200<br>
From: Sandro Santilli <<a href="mailto:strk@keybit.net">strk@keybit.net</a>><br>
To: PostGIS Development Discussion <<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a>><br>
Subject: Re: [postgis-devel] creating topology<br>
Message-ID: <20130717204634.GB3543@gnash><br>
Content-Type: text/plain; charset=us-ascii<br>
<br>
Hi Paul,<br>
sorry for the late answer, I hope you still have your use case around.<br>
Replies inline.<br>
<br>
On Thu, Jun 27, 2013 at 03:24:08PM +0200, Paul Goldstein wrote:<br>
<br>
> I'm creating a topology of about 70k of geometry-segments. The<br>
> smallest of them is just a few meters, the longest is about 10 km<br>
> long.<br>
<br>
[...]<br>
<br>
> # part 1 #<br>
> With help of strk in postgis-irc (thanks again!) it took about 3<br>
> hours. It was made by divide all geometries in chunks by their id. One<br>
> chunk were 1000 pieces.<br>
<br>
I've seen that chunks of 500 pieces were faster, did you try 100 ?<br>
<br>
[...]<br>
<br>
> # part 2 #<br>
> I tried to switch off autovacuum (autovacuum_enabled = false) for all<br>
> tables in topology-scheme and for my segment-table. This was a massive<br>
> speed-improvement cause it took "only" 2 hours.<br>
> But strangely there was a knee after 42k of updates where speed<br>
> raises. - I don't know why.<br>
<br>
Maybe indices started being used, for some reason ? Hard to tell.<br>
<br>
Topology building leaves a lot of dead tuples around, so possibly<br>
a vacuum every now and then helps. Could you try running a<br>
vacuum analyze after 40k updates ?<br>
<br>
It's also curious how speed decreases before 40k and before 60k<br>
<br>
<br>
> # part 4 #<br>
> strk asked me to measure another idea: creating chunks not on their id<br>
> instead use their geographic coordinates. so one part is e.g. (0 0, 1<br>
> 1) -> (1 0, 2 1) -> (2 0, 3 1) ---> (0 1, 1 2) -> (1 1, 2 2) -> (2 1,<br>
> 3 2) ---> ... - i hope its clear what i meant.<br>
> thats my appropriate statement:<br>
><br>
> update public.segment<br>
> set topogeom = topology.totopogeom(st_force_2d(geom), 'segment_topo', 1, 0)<br>
> where (st_intersects(geom, st_envelope(st_geomfromewkt(?))) = true<br>
> or st_contains(geom, st_envelope(st_geomfromewkt(?))) = true)<br>
> and topogeom is null;<br>
><br>
> where ? is this: "srid=4326;linestring(%f %f,%f %f)"<br>
><br>
> This took very too long. I aborted it after 1,5 hours, because it was too slow.<br>
<br>
Pity, your fastest run lasted 2 hours...<br>
For sure the curve seems more "regular" :)<br>
<br>
> Now my questions:<br>
> Does anybody know how to improve the speed to create a topology?<br>
<br>
You already found a couple of good ways, those would be worth noting<br>
somewhere (postgis wiki would be a good place). If you still have that<br>
dataset I'd be curious to see the curve with smaller chunks, then with<br>
manual VACUUM ANALYZE added and maybe finally with geometries ordered<br>
by number of vertices (fewer vertices first).<br>
<br>
> Or is it possible to not creating my topology every night if something<br>
> changes in geometry. Instead alter topology in an<br>
> after-statement-trigger when something happens with geometries.<br>
<br>
You can surely call toTopoGeom again with the modified geometry.<br>
With PostGIS-2.1 the function also accepts the old TopoGeometry to<br>
effectively replace it (rather than leaving an orphaned TopoGeometry<br>
around). You'll still need to "manually" remove primitives (edges,<br>
nodes) that are not used anymore. They won't hurt, but with time they<br>
tend to slow things down.<br>
<br>
> strk said when totopogeom() is called TopoGeo_addLinestring() is<br>
> entered many times. Is it possible to improve that function? (Maybe<br>
> writing it in C - instead of plpgsql :)<br>
<br>
Yes, writing that function in C may considerably speed things up, but<br>
there's currently nobody working on it. Contributions are welcome.<br>
<br>
> Here you can see some graphs for the different parts:<br>
> <a href="http://privatepaste.com/download/ef41296b0d" target="_blank">http://privatepaste.com/download/ef41296b0d</a><br>
> blue is part 1: chunks of ids<br>
> red is part 2: chunks of ids but without autovacuum<br>
> yellow is part 3: as red but 96MB of shared_buffer<br>
> green is part 4: chunks of squared geography elements<br>
><br>
> Thanks for any help or suggestions,<br>
<br>
Thank you for the excellent report !<br>
<br>
--strk;<br>
<br>
<a href="http://www.cartodb.com" target="_blank">http://www.cartodb.com</a> - Map, analyze and build applications with your data<br>
<br>
~~ <a href="http://strk.keybit.net" target="_blank">http://strk.keybit.net</a><br>
<br>
<br>
<br>
------------------------------<br>
<br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org">postgis-devel@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel" target="_blank">http://lists.osgeo.org/cgi-bin/mailman/listinfo/postgis-devel</a><br>
<br>
<br>
End of postgis-devel Digest, Vol 124, Issue 9<br>
*********************************************<br>
</blockquote></div>