From: Brian Quinion Date: Thu, 6 Feb 2014 16:50:41 +0000 (+0000) Subject: Script to automatically warm the postgresql query before sending traffic X-Git-Tag: v2.2.0~10 X-Git-Url: https://git.openstreetmap.org./nominatim.git/commitdiff_plain/edc5733715a65158919c1abc4d765b754f5dc659 Script to automatically warm the postgresql query before sending traffic --- diff --git a/utils/warm.php b/utils/warm.php new file mode 100755 index 00000000..923e2aba --- /dev/null +++ b/utils/warm.php @@ -0,0 +1,63 @@ +#!/usr/bin/php -Cq +setIncludeAddressDetails(true); + + echo "Warm reverse: "; + if ($bVerbose) echo "\n"; + for($i = 0; $i < 1000; $i++) { + $fLat = rand(-9000, 9000) / 100; + $fLon = rand(-18000, 18000) / 100; + if ($bVerbose) echo "$fLat, $fLon = "; + $oReverseGeocode->setLanguagePreference(array('en')); + $oReverseGeocode->setLatLon($fLat, $fLon); + $oReverseGeocode->setZoom(20); + $aDetails = $oReverseGeocode->lookup(); + if ($bVerbose) echo $aDetails['langaddress']."\n"; + else echo "."; + } + echo "\n"; + } + + if (!$aResult['reverse-only']) { + + $oGeocode =& new Geocode($oDB); + + echo "Warm search: "; + if ($bVerbose) echo "\n"; + $sSQL = 'select word from word where word is not null order by search_name_count desc limit 1000'; + foreach($oDB->getCol($sSQL) as $sWord) { + if ($bVerbose) echo "$sWord = "; + $oGeocode->setLanguagePreference(array('en')); + $oGeocode->setQuery($sWord); + $aSearchResults = $oGeocode->lookup(); + if ($bVerbose) echo $aSearchResults[0]['langaddress']."\n"; + else echo "."; + } + } +