From: Sarah Hoffmann Date: Sun, 20 Nov 2022 19:22:44 +0000 (+0100) Subject: force use of geometry index for reverse polygon lookup X-Git-Tag: v4.2.0~6^2 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/77acc1c2be0c5fea487825a5e6a5a083e2b62569 force use of geometry index for reverse polygon lookup --- diff --git a/lib-php/ReverseGeocode.php b/lib-php/ReverseGeocode.php index 7732ffbc..d12e4da3 100644 --- a/lib-php/ReverseGeocode.php +++ b/lib-php/ReverseGeocode.php @@ -189,7 +189,8 @@ class ReverseGeocode $sSQL .= '(select place_id, parent_place_id, rank_address, rank_search, country_code, geometry'; $sSQL .= ' FROM placex'; $sSQL .= ' WHERE ST_GeometryType(geometry) in (\'ST_Polygon\', \'ST_MultiPolygon\')'; - $sSQL .= ' AND rank_search between 5 and ' .$iMaxRank; + // Ensure that query planner doesn't use the index on rank_search. + $sSQL .= ' AND coalesce(rank_search, 0) between 5 and ' .$iMaxRank; $sSQL .= ' AND rank_address between 4 and 25'; // needed for index selection $sSQL .= ' AND geometry && '.$sPointSQL; $sSQL .= ' AND type != \'postcode\' ';