Created
January 3, 2012 00:13
-
-
Save kingcu/1552738 to your computer and use it in GitHub Desktop.
nominatim loaddata modification for memory savings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CREATE OR REPLACE FUNCTION load_this_shit() RETURNS integer AS $$ | |
DECLARE | |
rec place%rowtype; | |
BEGIN | |
FOR rec in SELECT * FROM place WHERE osm_type IN ('N', 'W', 'R') LOOP | |
EXECUTE 'INSERT INTO placex values (' | |
|| quote_nullable(rec.place_id) || ',' | |
|| quote_nullable(rec.osm_type) || ',' | |
|| quote_nullable(rec.osm_id) || ',' | |
|| quote_nullable(rec.class) || ',' | |
|| quote_nullable(rec.type) || ',' | |
|| quote_nullable(rec.name) || ',' | |
|| quote_nullable(rec.admin_level) || ',' | |
|| quote_nullable(rec.housenumber) || ',' | |
|| quote_nullable(rec.street) || ',' | |
|| quote_nullable(rec.isin) || ',' | |
|| quote_nullable(rec.postcode) || ',' | |
|| quote_nullable(rec.country_code) || ',' | |
|| quote_nullable(rec.street_place_id) || ',' | |
|| quote_nullable(rec.rank_address) || ',' | |
|| quote_nullable(rec.rank_search) || ',' | |
|| quote_nullable(rec.indexed) || ',' | |
|| quote_nullable(CAST(rec.geometry As text)) || ')'; | |
END LOOP; | |
END; | |
$$ LANGUAGE plpgsql; | |
SELECT load_this_shit() as Answer; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment