optimisation INSERT geo
This commit is contained in:
parent
071005528f
commit
ee082a91de
1 changed files with 3 additions and 4 deletions
|
@ -112,10 +112,9 @@ class EventsResource(BaseEvent):
|
|||
class EventResource(BaseEvent):
|
||||
def maybe_insert_geometry(self, geometry, cur):
|
||||
# insert into geo table if not existing
|
||||
cur.execute("""INSERT INTO geo (hash, geom, geom_center)
|
||||
SELECT *, st_centroid(geom) FROM
|
||||
(SELECT md5(ewkt) as hash, st_setsrid(st_geomfromewkt(ewkt),4326) as geom FROM
|
||||
(SELECT st_asewkt(st_geomfromgeojson( %s )) as ewkt) as g) as i
|
||||
cur.execute("""INSERT INTO geo
|
||||
SELECT geom, md5(st_asewkt(geom)) as hash, st_centroid(geom) as geom_center FROM
|
||||
(SELECT st_setsrid(st_geomfromgeojson( %s ),4326) as geom) as g
|
||||
WHERE ST_IsValid(geom)
|
||||
ON CONFLICT DO NOTHING RETURNING hash;""",
|
||||
(geometry,))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue