mirror of
https://github.com/osm-search/Nominatim.git
synced 2026-03-06 18:14:16 +00:00
split up query for deletable endpoint by osm type
This is needed to ensure index use on placex.
This commit is contained in:
@@ -374,14 +374,17 @@ async def deletable_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any
|
|||||||
"""
|
"""
|
||||||
fmt = parse_format(params, RawDataList, 'json')
|
fmt = parse_format(params, RawDataList, 'json')
|
||||||
|
|
||||||
|
results = RawDataList()
|
||||||
async with api.begin() as conn:
|
async with api.begin() as conn:
|
||||||
sql = sa.text(""" SELECT p.place_id, country_code,
|
for osm_type in ('N', 'W', 'R'):
|
||||||
name->'name' as name, i.*
|
sql = sa.text(""" SELECT p.place_id, country_code,
|
||||||
FROM placex p, import_polygon_delete i
|
name->'name' as name, i.*
|
||||||
WHERE p.osm_id = i.osm_id AND p.osm_type = i.osm_type
|
FROM placex p, import_polygon_delete i
|
||||||
AND p.class = i.class AND p.type = i.type
|
WHERE i.osm_type = :osm_type
|
||||||
""")
|
AND p.osm_id = i.osm_id AND p.osm_type = :osm_type
|
||||||
results = RawDataList(r._asdict() for r in await conn.execute(sql))
|
AND p.class = i.class AND p.type = i.type
|
||||||
|
""")
|
||||||
|
results.extend(r._asdict() for r in await conn.execute(sql, {'osm_type': osm_type}))
|
||||||
|
|
||||||
return build_response(params, params.formatting().format_result(results, fmt, {}))
|
return build_response(params, params.formatting().format_result(results, fmt, {}))
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user