]> granicus.if.org Git - postgis/commitdiff
4x speed improvement in GetFaceByPoint
authorSandro Santilli <strk@kbt.io>
Sat, 3 Dec 2016 22:05:08 +0000 (22:05 +0000)
committerSandro Santilli <strk@kbt.io>
Sat, 3 Dec 2016 22:05:08 +0000 (22:05 +0000)
Implies a speedup in topology loading too, whereas the
face-containing-point callback is used twice per added line.

git-svn-id: http://svn.osgeo.org/postgis/trunk@15269 b70326c6-7e19-0410-871a-916f4a2858ee

topology/postgis_topology.c

index 7665c6149dbaae4ad4f57964794414a3cacf7459..cbd3ecdc5edbc4afd0507739ce9e55d63dbc0495 100644 (file)
@@ -2529,8 +2529,9 @@ cb_getFaceContainingPoint( const LWT_BE_TOPOLOGY* topo, const LWPOINT* pt )
   }
   /* 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);