]> git.openstreetmap.org Git - nominatim.git/commitdiff
avoid unnecessary SQL when rechecking rank restrictions
authorSarah Hoffmann <lonvia@denofr.de>
Mon, 2 Oct 2017 18:42:37 +0000 (20:42 +0200)
committerSarah Hoffmann <lonvia@denofr.de>
Mon, 2 Oct 2017 18:42:37 +0000 (20:42 +0200)
lib/Geocode.php

index fc2d6c65190ee17ecd0949c0f8c837336e88604f..0c2a9963e639ce44f785a060190ebb32e4d9b0a2 100644 (file)
@@ -1739,20 +1739,19 @@ class Geocode
                     if ($this->aAddressRankList) {
                         $sSQL .= "     OR placex.rank_address in (".join(',', $this->aAddressRankList).")";
                     }
-                    if (CONST_Use_US_Tiger_Data) {
-                        $sSQL .= "  ) ";
+                    $sSQL .= "  ) ";
+                    if (CONST_Use_US_Tiger_Data && $this->iMaxAddressRank == 30) {
                         $sSQL .= "UNION ";
                         $sSQL .= "  SELECT place_id ";
                         $sSQL .= "  FROM location_property_tiger ";
                         $sSQL .= "  WHERE place_id in (".join(',', array_keys($aResultPlaceIDs)).") ";
-                        $sSQL .= "    AND (30 between $this->iMinAddressRank and $this->iMaxAddressRank ";
-                        if ($this->aAddressRankList) $sSQL .= " OR 30 in (".join(',', $this->aAddressRankList).")";
                     }
-                    $sSQL .= ") UNION ";
-                    $sSQL .= "  SELECT place_id ";
-                    $sSQL .= "  FROM location_property_osmline ";
-                    $sSQL .= "  WHERE place_id in (".join(',', array_keys($aResultPlaceIDs)).")";
-                    $sSQL .= "    AND startnumber is not NULL AND (30 between $this->iMinAddressRank and $this->iMaxAddressRank)";
+                    if ($this->iMaxAddressRank == 30) {
+                        $sSQL .= "UNION ";
+                        $sSQL .= "  SELECT place_id ";
+                        $sSQL .= "  FROM location_property_osmline ";
+                        $sSQL .= "  WHERE place_id in (".join(',', array_keys($aResultPlaceIDs)).")";
+                    }
                     if (CONST_Debug) var_dump($sSQL);
                     $aFilteredPlaceIDs = chksql($this->oDB->getCol($sSQL));
                     $tempIDs = array();