From: Sandro Santilli Date: Sat, 3 Dec 2016 22:05:08 +0000 (+0000) Subject: 4x speed improvement in GetFaceByPoint X-Git-Tag: 2.4.0alpha~195 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f345052648297045d89c31e331de0497eaf1baf3;p=postgis 4x speed improvement in GetFaceByPoint 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 --- diff --git a/topology/postgis_topology.c b/topology/postgis_topology.c index 7665c6149..cbd3ecdc5 100644 --- a/topology/postgis_topology.c +++ b/topology/postgis_topology.c @@ -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);