From f345052648297045d89c31e331de0497eaf1baf3 Mon Sep 17 00:00:00 2001 From: Sandro Santilli Date: Sat, 3 Dec 2016 22:05:08 +0000 Subject: [PATCH] 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 --- topology/postgis_topology.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) 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); -- 2.40.0