From 77acc1c2be0c5fea487825a5e6a5a083e2b62569 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Sun, 20 Nov 2022 20:22:44 +0100 Subject: [PATCH] force use of geometry index for reverse polygon lookup --- lib-php/ReverseGeocode.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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\' '; -- 2.39.5