From: Regina Obe Date: Wed, 11 May 2011 14:59:55 +0000 (+0000) Subject: more optimizations X-Git-Tag: 2.0.0alpha1~1677 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=14e23035f22606b9fe5377b0aec9c2b3e6de6b22;p=postgis more optimizations git-svn-id: http://svn.osgeo.org/postgis/trunk@7131 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extras/tiger_geocoder/tiger_2010/normalize/location_extract_place_exact.sql b/extras/tiger_geocoder/tiger_2010/normalize/location_extract_place_exact.sql index 62fc7da06..1ab610164 100644 --- a/extras/tiger_geocoder/tiger_2010/normalize/location_extract_place_exact.sql +++ b/extras/tiger_geocoder/tiger_2010/normalize/location_extract_place_exact.sql @@ -21,11 +21,12 @@ BEGIN IF stateAbbrev IS NOT NULL THEN lstate := statefp FROM state WHERE stusps = stateAbbrev; SELECT INTO tempInt count(*) FROM place - WHERE place.statefp = lstate + WHERE place.statefp = lstate AND fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || name || '$'); ELSE SELECT INTO tempInt count(*) FROM place - WHERE texticregexeq(fullStreet, '(?i)' || name || '$'); + WHERE fullStreet ILIKE '%' || name || '%' AND + texticregexeq(fullStreet, '(?i)' || name || '$'); END IF; IF tempInt > 0 THEN @@ -33,7 +34,7 @@ BEGIN IF stateAbbrev IS NOT NULL THEN FOR rec IN SELECT substring(fullStreet, '(?i)(' || name || ')$') AS value, name FROM place - WHERE place.statefp = lstate + WHERE place.statefp = lstate AND fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || name || '$') ORDER BY length(name) DESC LOOP -- Since the regex is end of string, only the longest (first) result @@ -44,7 +45,7 @@ BEGIN ELSE FOR rec IN SELECT substring(fullStreet, '(?i)(' || name || ')$') AS value, name FROM place - WHERE texticregexeq(fullStreet, '(?i)' + WHERE fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || name || '$') ORDER BY length(name) DESC LOOP -- Since the regex is end of string, only the longest (first) result -- is useful. diff --git a/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql b/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql index 76ca40dae..43bf38043 100644 --- a/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql +++ b/extras/tiger_geocoder/tiger_2010/normalize/normalize_address.sql @@ -225,14 +225,14 @@ BEGIN -- or suite number. -- this count is surprisingly slow by itself but much faster if you add an ILIKE AND clause SELECT INTO tempInt count(*) FROM secondary_unit_lookup - WHERE texticregexeq(fullStreet, '(?i)' || ws || name || '(' + WHERE fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || ws || name || '(' || ws || '|$)'); IF tempInt = 1 THEN result.internal := substring(fullStreet, '(?i)' || ws || '(' || name || ws || '*#?' || ws || '*(?:[0-9][-0-9a-zA-Z]*)?' || ')(?:' || ws || '|$)') FROM secondary_unit_lookup - WHERE texticregexeq(fullStreet, '(?i)' || ws || name || '(' + WHERE fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || ws || name || '(' || ws || '|$)'); ELSIF tempInt > 1 THEN -- In the event of multiple matches to a secondary unit designation, we @@ -242,7 +242,7 @@ BEGIN || name || '(?:' || ws || '*#?' || ws || '*(?:[0-9][-0-9a-zA-Z]*)?)' || ws || '?|$)')) as value FROM secondary_unit_lookup - WHERE texticregexeq(fullStreet, '(?i)' || ws || name || '(' + WHERE fullStreet ILIKE '%' || name || '%' AND texticregexeq(fullStreet, '(?i)' || ws || name || '(' || ws || '|$)') LOOP IF tempInt < position(rec.value in fullStreet) THEN tempInt := position(rec.value in fullStreet);