]> granicus.if.org Git - postgis/commitdiff
Use a CTE for queries involving largs WKB input.
authorSandro Santilli <strk@keybit.net>
Mon, 16 Jan 2012 08:25:08 +0000 (08:25 +0000)
committerSandro Santilli <strk@keybit.net>
Mon, 16 Jan 2012 08:25:08 +0000 (08:25 +0000)
Reduces parsing and execution time.

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

topology/sql/populate.sql.in.c

index dbb1c0d72d5cabbc655849453c33089fe0e13a12..830057c379408671edccc79aa9b881599402dbca 100644 (file)
@@ -759,14 +759,14 @@ BEGIN
 #endif
 
   -- 2. Node to edges and nodes falling within tolerance distance
-  sql := 'WITH nearby AS ( SELECT geom FROM ' 
+  sql := 'WITH line AS ( SELECT '
+    || quote_literal(aline::text)
+    || '::geometry as g ), nearby AS ( SELECT n.geom FROM ' 
     || quote_ident(atopology) 
-    || '.node WHERE ST_DWithin(geom,'
-    || quote_literal(aline::text) || '::geometry,'
-    || tolerance || ') UNION ALL SELECT geom FROM '
+    || '.node n, line l WHERE ST_DWithin(n.geom, l.g, '
+    || tolerance || ') UNION ALL SELECT e.geom FROM '
     || quote_ident(atopology) 
-    || '.edge WHERE ST_DWithin(geom,'
-    || quote_literal(aline::text) || '::geometry,'
+    || '.edge e, line l WHERE ST_DWithin(e.geom, l.g, '
     || tolerance || ') ) SELECT st_collect(geom) FROM nearby;';
 #ifdef POSTGIS_TOPOLOGY_DEBUG
   RAISE DEBUG '%', sql;