Skip to content

Commit 33c0f24

Browse files
committed
avoid LookupAny with address and too many name tokens
The index for nameaddress_vector has grown so large that PostgreSQL will resort to a sequential scan if there are too many items in the LookupAny list.
1 parent 76eadc5 commit 33c0f24

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

nominatim/api/search/db_search_builder.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -176,11 +176,12 @@ def build_housenumber_search(self, sdata: dbf.SearchData, hnrs: List[Token],
176176
sdata.lookups.append(dbf.FieldLookup('nameaddress_vector',
177177
list(partials), lookups.LookupAll))
178178
else:
179+
addr_fulls = [t.token for t
180+
in self.query.get_tokens(address[0], TokenType.WORD)]
181+
if len(addr_fulls) > 5:
182+
return
179183
sdata.lookups.append(
180-
dbf.FieldLookup('nameaddress_vector',
181-
[t.token for t
182-
in self.query.get_tokens(address[0], TokenType.WORD)],
183-
lookups.LookupAny))
184+
dbf.FieldLookup('nameaddress_vector', addr_fulls, lookups.LookupAny))
184185

185186
sdata.housenumbers = dbf.WeightedStrings([], [])
186187
yield dbs.PlaceSearch(0.05, sdata, expected_count)

0 commit comments

Comments
 (0)