mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-02-26 11:08:13 +00:00
avoid index on rank_address in near search
This commit is contained in:
@@ -24,6 +24,13 @@ from nominatim.db.sqlalchemy_types import Geometry
|
|||||||
#pylint: disable=singleton-comparison,not-callable
|
#pylint: disable=singleton-comparison,not-callable
|
||||||
#pylint: disable=too-many-branches,too-many-arguments,too-many-locals,too-many-statements
|
#pylint: disable=too-many-branches,too-many-arguments,too-many-locals,too-many-statements
|
||||||
|
|
||||||
|
def no_index(expr: SaColumn) -> SaColumn:
|
||||||
|
""" Wrap the given expression, so that the query planner will
|
||||||
|
refrain from using the expression for index lookup.
|
||||||
|
"""
|
||||||
|
return sa.func.coalesce(sa.null(), expr) # pylint: disable=not-callable
|
||||||
|
|
||||||
|
|
||||||
def _details_to_bind_params(details: SearchDetails) -> Dict[str, Any]:
|
def _details_to_bind_params(details: SearchDetails) -> Dict[str, Any]:
|
||||||
""" Create a dictionary from search parameters that can be used
|
""" Create a dictionary from search parameters that can be used
|
||||||
as bind parameter for SQL execute.
|
as bind parameter for SQL execute.
|
||||||
@@ -295,7 +302,7 @@ class NearSearch(AbstractSearch):
|
|||||||
else_ = tgeom.c.centroid.ST_Expand(0.05))))\
|
else_ = tgeom.c.centroid.ST_Expand(0.05))))\
|
||||||
.order_by(tgeom.c.centroid.ST_Distance(table.c.centroid))
|
.order_by(tgeom.c.centroid.ST_Distance(table.c.centroid))
|
||||||
|
|
||||||
sql = sql.where(t.c.rank_address.between(MIN_RANK_PARAM, MAX_RANK_PARAM))
|
sql = sql.where(no_index(t.c.rank_address).between(MIN_RANK_PARAM, MAX_RANK_PARAM))
|
||||||
if details.countries:
|
if details.countries:
|
||||||
sql = sql.where(t.c.country_code.in_(COUNTRIES_PARAM))
|
sql = sql.where(t.c.country_code.in_(COUNTRIES_PARAM))
|
||||||
if details.excluded:
|
if details.excluded:
|
||||||
|
|||||||
Reference in New Issue
Block a user