[postgis-users] creating topology data is slow

Marc-André Goderre magoderre at cgq.qc.ca
Tue Jun 2 10:25:02 PDT 2015


Hello all,
I'm creating topology data from almost all world road OSM data ( More than 77 Million ways).
Processing the data  with postgis topology in one shot is so long than that I created a hexagonal grid that let me create topological data from only one or many cell of the grid.
Even this way, It' s going to take many month to process the world's data.
Is there a way to make it faster?
This is my function that I use to process data.

CREATE OR REPLACE FUNCTION cm_update_tile_data(tile_id integer)
  RETURNS character varying AS
$BODY$
DECLARE r RECORD;

BEGIN
  FOR r IN SELECT * FROM way, join world_grid  on line&& the_geom where gid=tile_id and topo_geom is NULL LOOP
    BEGIN
      UPDATE way
SET topo_geom = topology.toTopoGeom(st_force2d(line), 'way_topo', 1)
      WHERE id = r.id;
    EXCEPTION
      WHEN OTHERS THEN
        RAISE WARNING 'Loading of record % failed: %', r.id, SQLERRM;
    END;
  END LOOP;
  UPDATE world_grid set last_update = now() where gid=tile_id;
  return 'OK';
END
$BODY$
  LANGUAGE plpgsql VOLATILE
  COST 100;

Thanks

Marc

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20150602/5409232e/attachment.html>


More information about the postgis-users mailing list