]> git.openstreetmap.org Git - nominatim.git/commitdiff
frequent words hack
authorSarah Hoffmann <lonvia@denofr.de>
Sat, 10 Mar 2012 10:48:02 +0000 (11:48 +0100)
committerSarah Hoffmann <lonvia@denofr.de>
Sat, 10 Mar 2012 10:48:02 +0000 (11:48 +0100)
Adds logging of queries on search_name that take too long
because of word tokens that are too frequent.
Words can be excluded from the token search by setting the
search_name_count column to something greater than 0.

website/search.php

index d9adf6b849088b4a0eef95245087495cf2396eab..fd91f31daff2831f349c0b5f5ce8725c306b1436 100755 (executable)
                        // Check which tokens we have, get the ID numbers                       
                        $sSQL = 'select word_id,word_token, word, class, type, location, country_code, operator';
                        $sSQL .= ' from word where word_token in ('.join(',',array_map("getDBQuoted",$aTokens)).')';
-                       $sSQL .= ' and (class is null or class not in (\'highway\'))';
+                       // HACK WARNING
+                       // (mis)using search_name_count to exclude words that return too many
+                       // search results. saerch_name_count is currently set to 1 by hand
+                       // because there is no fast way to extract this count from a live database. 
+                       $sSQL .= ' and search_name_count = 0';
+//                     $sSQL .= ' and (class is null or class not in (\'highway\'))';
 //                     $sSQL .= ' group by word_token, word, class, type, location, country_code';
 
                        if (CONST_Debug) var_Dump($sSQL);
                                                                        $sSQL .= " limit ".$iLimit;
 
                                                                if (CONST_Debug) var_dump($sSQL);
+                                                               $iStartTime = time();
                                                                $aViewBoxPlaceIDs = $oDB->getAll($sSQL);
                                                                if (PEAR::IsError($aViewBoxPlaceIDs))
                                                                {
                                                                        var_dump($sSQL, $aViewBoxPlaceIDs);                                     
                                                                        exit;
                                                                }
+                                                               if (time() - $iStartTime > 60) {
+                                                                       file_put_contents(CONST_BasePath.'/log/long_queries.log', date('Y-m-d H:i:s', $iStartTime).' '.$sSQL."\n", FILE_APPEND);
+                                                               }
+
 //var_dump($aViewBoxPlaceIDs);
                                                                // Did we have an viewbox matches?
                                                                $aPlaceIDs = array();