]> granicus.if.org Git - postgis/commitdiff
Reduce number of queries by one within ST_ModEdgeSplit
authorSandro Santilli <strk@keybit.net>
Tue, 23 Jun 2015 12:41:04 +0000 (12:41 +0000)
committerSandro Santilli <strk@keybit.net>
Tue, 23 Jun 2015 12:41:04 +0000 (12:41 +0000)
Uses "INSERT RETURNING" rather than "SELECT" and "INSERT" for
getting the identifier of new node.

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

topology/sql/sqlmm.sql.in

index 79e1bd2414d7faead21aa0a5de3960bd02f3d7cc..dab993d0f9389256463e83a0a559c0ff35b5851d 100644 (file)
@@ -2183,23 +2183,15 @@ BEGIN
   END LOOP;
 
   --
-  -- Get new node id
-  --
-  FOR rec IN EXECUTE 'SELECT nextval(''' ||
-    atopology || '.node_node_id_seq'')'
-  LOOP
-    nodeid = rec.nextval;
-  END LOOP;
-
-  --RAISE NOTICE 'Next node id = % ', nodeid;
-
-  --
-  -- Add the new node 
+  -- Add the new node, returning its identifier
   --
   EXECUTE 'INSERT INTO ' || quote_ident(atopology)
-    || '.node(node_id, geom) VALUES($1, $2)'
+    || '.node(node_id, geom) VALUES(DEFAULT, $2) RETURNING node_id'
+    INTO nodeid
     USING nodeid,apoint;
 
+  --RAISE NOTICE 'Next node id = % ', nodeid;
+
   --
   -- Compute new edge
   --