<div dir="ltr">Hey,<div>whatever you do, </div><div>if you call 9 millions times a plpgsql function (with subsequent multiple other function calls, and lots of exception handling) I'm afraid it will be "slow" !</div>
<div><br>
</div><div>I don"t know precisely the operation done when inserting a polygon into the topology, but theoretically, we need at least to look if it doesn't intersect other topology (meaning for each insertion, you have to check all other already existing topology, theoretically ln(n)) if using an index))</div>
<div><br></div><div>That would be n*ln(n) at best.</div><div><br></div><div>Now maybe there is a problem in the index uses? I'm not a pro of indexes, </div><div>Maybe you could try to insert your polygon K by K, refreshing the stats between each insertion?</div>
<div>(like insert 10k polygons, ANALYZE, insert 10k polygons, ...).</div><div><br></div><div><br></div><div>Another easy test would be to insert not at the topogeom level but at the topology level, maybe with function addface ?</div>
<div>This would help to know where the slowness is coming from</div><div><br></div><div>Cheers,</div><div>Rémi-C</div>
<div><br></div><div><br></div><div><br></div><div class="gmail_extra"><br><br><div class="gmail_quote">2014/1/7 Graeme B. Bell <span dir="ltr"><<a href="mailto:grb@skogoglandskap.no" target="_blank">grb@skogoglandskap.no</a>></span><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
Hi Remi<br>
<br>
Thanks very much for your reply.<br>
<br>
> hey,<br>
> if you have already topological data,<br>
> there is no point in using the normal function :<br>
<br>
Consider the polygonised raster. It is naturally topological (pixels of a raster don't overlap), but it has never been a topology in the postgis or oracle sense. In producing a simple feature dataset there's a possiblility that the polygonisation function has produced some very slight overlaps or gaps. Generally when the data has passed through simple feature geometry there is always the possibility that we have now got slight overlaps due to inaccuracies in number representation or subtleties of algorithm behaviour.<br>
<br>
The mention of topological properties was simply to highlight that this was not a case of perversely difficult data screwing up the postgis topology constructor, rather it's one of the easiest situations that the constructor can encounter, with few or zero overlaps between the polygons being imported.<br>
<br>
> These functions performs a lot of operations to ensure that when you insert<br>
> a polygon, you won't intersect with another one, etc etc.<br>
<br>
I think that is always a concern when adding simple feature geometry, due to uncertainties surrounding algorithm behaviour and number representation, especially when using such a large dataset which can't be manually inspected.<br>
<br>
> To gain speed , you could either cut your data into several different<br>
> topology schema (partitionning),<br>
<br>
It's a good idea which we have thought about too. Unfortunately we need to have a single topology here. "Gaining speed" against this algorithm would mean slicing the map into hundreds of pieces, not merely several. Also, splitting the topology up into lots of little fragments adds complexity to every application that uses the topology. A significant reason for using a topology is to have the map in one tidy, aggregated piece.<br>
<br>
> or put topology data the batch way (not one by one) , if possible ignoring<br>
> all the framework used for normal data but useless for already topological<br>
> data (possibly performing the necessary operation the set-way).<br>
<br>
I agree that it might be possible to make assumptions about the data and write our own constructors that remove safety checks. However we do not want to ignore the framework. We would want to use this on a range of maps and so we assume 'normal data' will be used.<br>
<br>
Also, removing safety checks may not help. I am not also certain that the slowness is from the geometry set constructor rather than the topology data type itself. The slowness when polygons are added incrementally makes me wonder.<br>
<br>
> A simple thing you could try is not adding polygon but edges to populate<br>
> your topological model,<br>
> then when you have imported all edges,<br>
> create a topogeometry per polygon and link it to your polygon data.<br>
> This would be done by breaking all your polygon into lines then edges (with<br>
> some creative use of split), removing the duplicate,<br>
> then populating the postgis topology<br>
> tables<<a href="http://trac.osgeo.org/postgis/wiki/PostgisTopology_Data_Model" target="_blank">http://trac.osgeo.org/postgis/wiki/PostgisTopology_Data_Model</a>>manually.<br>
><br>
> The keys would be never use a one object per one object function , but<br>
> instead sql querries on whole table.<br>
<br>
That's a good idea. Thanks. However... see my comment at the end.<br>
<br>
> Similarly it would be way faster and easer to directly import oracle<br>
> topology (i mean by pure data base manipulation, like table import/export).<br>
>> From what I see here<br>
> <<a href="http://docs.oracle.com/cd/B19306_01/appdev.102/b14256/sdo_topo_concepts.htm" target="_blank">http://docs.oracle.com/cd/B19306_01/appdev.102/b14256/sdo_topo_concepts.htm</a>>,<br>
> oracle topology and postgis topology data model seems very similar,<br>
> the conversion oracle-> postgis looking like just a copy of proper tables<br>
> and columns, the conversion postgis -> oracle looking a bit more difficult.<br>
<br>
Yes. It's probably possible to do that but it seems there is no out of the box solution.<br>
<br>
Regardless, we still need a topology constructor solution that works generally with all the datasets, not only the ones currently in oracle topology, and not just trivial cases.<br>
<br>
A concern at the back of my mind is that if the standard topology constructor (or datatype) is using O(n^2) algorithms, are we likely to encounter further similar problems in other functions (perhaps due to similarly written functions elsewhere or due to problems with the underlying datatype)? i.e. is this constructor performance problem the tip of an iceberg?<br>
<br>
Does anyone know if there have been any tests/measurements of postgis topology function performance as datasets get larger?<br>
<br>
Graeme.<br>
<br>
<br>
<br>
_______________________________________________<br>
postgis-devel mailing list<br>
<a href="mailto:postgis-devel@lists.osgeo.org" target="_blank">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>
</blockquote></div><br></div></div>