mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-11 21:34:06 +00:00
add prepared statement
This commit is contained in:
@@ -50,6 +50,10 @@ class IndexingThread(object):
|
|||||||
self.cursor = self.conn.cursor()
|
self.cursor = self.conn.cursor()
|
||||||
self.perform("SET lc_messages TO 'C'")
|
self.perform("SET lc_messages TO 'C'")
|
||||||
self.wait()
|
self.wait()
|
||||||
|
self.perform(InterpolationRunner.prepare())
|
||||||
|
self.wait()
|
||||||
|
self.perform(RankRunner.prepare())
|
||||||
|
self.wait()
|
||||||
|
|
||||||
self.current_query = None
|
self.current_query = None
|
||||||
|
|
||||||
@@ -74,7 +78,7 @@ class IndexingThread(object):
|
|||||||
raise RuntimeError("Postgres exception has no error code")
|
raise RuntimeError("Postgres exception has no error code")
|
||||||
if e.pgcode == '40P01':
|
if e.pgcode == '40P01':
|
||||||
log.info("Deadlock detected, retry.")
|
log.info("Deadlock detected, retry.")
|
||||||
self.cursor.execute(sql)
|
self.cursor.execute(self.sql)
|
||||||
else:
|
else:
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@@ -177,6 +181,12 @@ class RankRunner(object):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return "rank {}".format(self.rank)
|
return "rank {}".format(self.rank)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def prepare(cls):
|
||||||
|
return """PREPARE rnk_index AS
|
||||||
|
UPDATE placex
|
||||||
|
SET indexed_status = 0 WHERE place_id = $1"""
|
||||||
|
|
||||||
def sql_index_sectors(self):
|
def sql_index_sectors(self):
|
||||||
return """SELECT geometry_sector, count(*) FROM placex
|
return """SELECT geometry_sector, count(*) FROM placex
|
||||||
WHERE rank_search = {} and indexed_status > 0
|
WHERE rank_search = {} and indexed_status > 0
|
||||||
@@ -194,7 +204,7 @@ class RankRunner(object):
|
|||||||
ORDER BY geometry_sector"""
|
ORDER BY geometry_sector"""
|
||||||
|
|
||||||
def sql_index_place(self):
|
def sql_index_place(self):
|
||||||
return "UPDATE placex SET indexed_status = 0 WHERE place_id = %s"
|
return "EXECUTE rnk_index(%s)"
|
||||||
|
|
||||||
|
|
||||||
class InterpolationRunner(object):
|
class InterpolationRunner(object):
|
||||||
@@ -202,6 +212,12 @@ class InterpolationRunner(object):
|
|||||||
def name(self):
|
def name(self):
|
||||||
return "interpolation lines (location_property_osmline)"
|
return "interpolation lines (location_property_osmline)"
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def prepare(cls):
|
||||||
|
return """PREPARE ipl_index AS
|
||||||
|
UPDATE location_property_osmline
|
||||||
|
SET indexed_status = 0 WHERE place_id = $1"""
|
||||||
|
|
||||||
def sql_index_sectors(self):
|
def sql_index_sectors(self):
|
||||||
return """SELECT geometry_sector, count(*) FROM location_property_osmline
|
return """SELECT geometry_sector, count(*) FROM location_property_osmline
|
||||||
WHERE indexed_status > 0
|
WHERE indexed_status > 0
|
||||||
@@ -219,8 +235,7 @@ class InterpolationRunner(object):
|
|||||||
ORDER BY geometry_sector"""
|
ORDER BY geometry_sector"""
|
||||||
|
|
||||||
def sql_index_place(self):
|
def sql_index_place(self):
|
||||||
return """UPDATE location_property_osmline
|
return "EXECUTE ipl_index(%s)"
|
||||||
SET indexed_status = 0 WHERE place_id = %s"""
|
|
||||||
|
|
||||||
|
|
||||||
def nominatim_arg_parser():
|
def nominatim_arg_parser():
|
||||||
|
|||||||
Reference in New Issue
Block a user