From: Regina Obe Date: Sun, 8 May 2011 16:36:55 +0000 (+0000) Subject: Put in costing and make most of the functions either STABLE or IMMUTABLE. We were... X-Git-Tag: 2.0.0alpha1~1697 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f954c9730b7a9a3c6add0b4f179c76ec69f55c82;p=postgis Put in costing and make most of the functions either STABLE or IMMUTABLE. We were loosing a lot of cacheability of that. Also put in instructions in README how to upgrade the scripts. Will need to put this in the official docs too once cleaned that up a bit. git-svn-id: http://svn.osgeo.org/postgis/trunk@7111 b70326c6-7e19-0410-871a-916f4a2858ee --- diff --git a/extras/tiger_geocoder/tiger_2010/README b/extras/tiger_geocoder/tiger_2010/README index bfffe67cf..17939ec3e 100644 --- a/extras/tiger_geocoder/tiger_2010/README +++ b/extras/tiger_geocoder/tiger_2010/README @@ -48,3 +48,8 @@ SELECT g.rating, ST_X(geomout) As lon, ST_Y(geomout) As lat, (addy).* FROM geocode('1731 New Hampshire Avenue Northwest, Washington, DC 20010') As g; + +Steps to upgrade your install: +If you need to upgrade the geocoder -- run the create_geocode.sql. +CAUTION: The upgrade script will drop any table columns that have a norm_addy type for a column type. This is rarely if ever done so you should be fine. +We plan to fix this later. \ No newline at end of file diff --git a/extras/tiger_geocoder/tiger_2010/create_geocode.sql b/extras/tiger_geocoder/tiger_2010/create_geocode.sql index cfc2cfcd1..42d32712d 100644 --- a/extras/tiger_geocoder/tiger_2010/create_geocode.sql +++ b/extras/tiger_geocoder/tiger_2010/create_geocode.sql @@ -4,6 +4,8 @@ SET search_path TO tiger,public; BEGIN; -- Type used to pass around a normalized address between functions +-- This is s bit dangerous since it could potentially drop peoples tables +-- TODO: put in logic to check if any tables have norm_addy and don't drop if they do DROP TYPE IF EXISTS norm_addy CASCADE; CREATE TYPE norm_addy AS ( address INTEGER, diff --git a/extras/tiger_geocoder/tiger_2010/geocode/geocode.sql b/extras/tiger_geocoder/tiger_2010/geocode/geocode.sql index 0f20c910a..e09170a79 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/geocode.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/geocode.sql @@ -33,7 +33,7 @@ BEGIN RETURN; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql STABLE; CREATE OR REPLACE FUNCTION geocode( @@ -124,4 +124,5 @@ BEGIN RETURN; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql STABLE + COST 1000; diff --git a/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql b/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql index 228e5e954..e55bc96c1 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/geocode_address.sql @@ -157,6 +157,6 @@ BEGIN RETURN; END; $$ - LANGUAGE 'plpgsql' VOLATILE; + LANGUAGE 'plpgsql' STABLE COST 1000; diff --git a/extras/tiger_geocoder/tiger_2010/geocode/geocode_location.sql b/extras/tiger_geocoder/tiger_2010/geocode/geocode_location.sql index 2fe4a5174..d6ae4a669 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/geocode_location.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/geocode_location.sql @@ -81,4 +81,4 @@ BEGIN RETURN; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql STABLE COST 100; diff --git a/extras/tiger_geocoder/tiger_2010/geocode/includes_address.sql b/extras/tiger_geocoder/tiger_2010/geocode/includes_address.sql index 5244ec86d..ba561e1d9 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/includes_address.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/includes_address.sql @@ -91,4 +91,4 @@ BEGIN -- The address is not within the range RETURN FALSE; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql IMMUTABLE COST 100; diff --git a/extras/tiger_geocoder/tiger_2010/geocode/interpolate_from_address.sql b/extras/tiger_geocoder/tiger_2010/geocode/interpolate_from_address.sql index 024f96e58..e0fc43474 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/interpolate_from_address.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/interpolate_from_address.sql @@ -12,7 +12,7 @@ BEGIN result = interpolate_from_address(given_address, addr1, addr2, road); RETURN result; END -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql IMMUTABLE COST 100; -- interpolate_from_address(local_address, from_address_l, to_address_l, from_address_r, to_address_r, local_road) -- This function returns a point along the given geometry (must be linestring) @@ -55,4 +55,4 @@ BEGIN result = ST_Line_Interpolate_Point(road, part); RETURN result; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql IMMUTABLE COST 100; diff --git a/extras/tiger_geocoder/tiger_2010/geocode/rate_attributes.sql b/extras/tiger_geocoder/tiger_2010/geocode/rate_attributes.sql index 0e769bedd..54e9debbf 100644 --- a/extras/tiger_geocoder/tiger_2010/geocode/rate_attributes.sql +++ b/extras/tiger_geocoder/tiger_2010/geocode/rate_attributes.sql @@ -57,4 +57,4 @@ BEGIN directionWeight; return result; END; -$_$ LANGUAGE plpgsql; +$_$ LANGUAGE plpgsql STABLE COST 10;