From cf9e8d6b8e65b1861905d368a3646dda5da4acea Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Tue, 8 Jul 2025 11:03:29 +0200 Subject: [PATCH] split up query for deletable endpoint by osm type This is needed to ensure index use on placex. --- src/nominatim_api/v1/server_glue.py | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/nominatim_api/v1/server_glue.py b/src/nominatim_api/v1/server_glue.py index a6450bf2..4aba0f9d 100644 --- a/src/nominatim_api/v1/server_glue.py +++ b/src/nominatim_api/v1/server_glue.py @@ -374,14 +374,17 @@ async def deletable_endpoint(api: NominatimAPIAsync, params: ASGIAdaptor) -> Any """ fmt = parse_format(params, RawDataList, 'json') + results = RawDataList() async with api.begin() as conn: - sql = sa.text(""" SELECT p.place_id, country_code, - name->'name' as name, i.* - FROM placex p, import_polygon_delete i - WHERE p.osm_id = i.osm_id AND p.osm_type = i.osm_type - AND p.class = i.class AND p.type = i.type - """) - results = RawDataList(r._asdict() for r in await conn.execute(sql)) + for osm_type in ('N', 'W', 'R'): + sql = sa.text(""" SELECT p.place_id, country_code, + name->'name' as name, i.* + FROM placex p, import_polygon_delete i + WHERE i.osm_type = :osm_type + AND p.osm_id = i.osm_id AND p.osm_type = :osm_type + 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, {})) -- 2.39.5