From 7bd9094aaa39d4be375a94111e41e7307b92c602 Mon Sep 17 00:00:00 2001 From: Sarah Hoffmann Date: Mon, 25 Oct 2021 14:55:15 +0200 Subject: [PATCH] reverse: add index hints The fairly complex where condition of idx_placex_geometry_placenode won't always be matched by the query planner if the condition part doesn't appear verbatim in the query. Fixes #2480. --- lib-php/ReverseGeocode.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib-php/ReverseGeocode.php b/lib-php/ReverseGeocode.php index 47e931ef..a670c623 100644 --- a/lib-php/ReverseGeocode.php +++ b/lib-php/ReverseGeocode.php @@ -111,6 +111,7 @@ class ReverseGeocode $sSQL .= ' FROM placex'; $sSQL .= ' WHERE osm_type = \'N\''; $sSQL .= ' AND country_code = \''.$sCountryCode.'\''; + $sSQL .= ' AND rank_search < 26 '; // needed to select right index $sSQL .= ' AND rank_search between 5 and ' .min(25, $iMaxRank); $sSQL .= ' AND class = \'place\' AND type != \'postcode\''; $sSQL .= ' AND name IS NOT NULL '; @@ -206,6 +207,7 @@ class ReverseGeocode // for place nodes at rank_address 16 $sSQL .= ' AND rank_search > '.$iRankSearch; $sSQL .= ' AND rank_search <= '.$iMaxRank; + $sSQL .= ' AND rank_search < 26 '; // needed to select right index $sSQL .= ' AND rank_address > 0'; $sSQL .= ' AND class = \'place\''; $sSQL .= ' AND type != \'postcode\''; -- 2.39.5