[postgis-tickets] r15269 - 4x speed improvement in GetFaceByPoint

Sandro Santilli strk at kbt.io
Sat Dec 3 14:05:08 PST 2016


Author: strk
Date: 2016-12-03 14:05:08 -0800 (Sat, 03 Dec 2016)
New Revision: 15269

Modified:
   trunk/topology/postgis_topology.c
Log:
4x speed improvement in GetFaceByPoint

Implies a speedup in topology loading too, whereas the
face-containing-point callback is used twice per added line.

Modified: trunk/topology/postgis_topology.c
===================================================================
--- trunk/topology/postgis_topology.c	2016-12-03 20:39:18 UTC (rev 15268)
+++ trunk/topology/postgis_topology.c	2016-12-03 22:05:08 UTC (rev 15269)
@@ -2529,8 +2529,9 @@
   }
   /* TODO: call GetFaceGeometry internally, avoiding the round-trip to sql */
   appendStringInfo(sql,
-                   "SELECT face_id FROM \"%s\".face "
-                   "WHERE mbr && $1 AND _ST_Contains("
+                   "WITH faces AS ( SELECT face_id FROM \"%s\".face "
+                   "WHERE mbr && $1 ORDER BY ST_Area(mbr) ASC ) "
+                   "SELECT face_id FROM faces WHERE _ST_Contains("
                    "topology.ST_GetFaceGeometry('%s', face_id), $1)"
                    " LIMIT 1",
                    topo->name, topo->name);



More information about the postgis-tickets mailing list