X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/12f830fbbb9177d8a4d172b2da2ed37dfa9c5fc4..9afebddb16b09e09fa9a74624dcd79475b476f10:/sql/tables.sql diff --git a/sql/tables.sql b/sql/tables.sql index 0245e3c3..8647e304 100644 --- a/sql/tables.sql +++ b/sql/tables.sql @@ -1,6 +1,6 @@ drop table if exists import_status; CREATE TABLE import_status ( - lastimportdate timestamp NOT NULL, + lastimportdate timestamp with time zone NOT NULL, sequence_id integer, indexed boolean ); @@ -176,7 +176,8 @@ CREATE INDEX idx_placex_osmid ON placex USING BTREE (osm_type, osm_id) {ts:searc CREATE INDEX idx_placex_linked_place_id ON placex USING BTREE (linked_place_id) {ts:address-index} WHERE linked_place_id IS NOT NULL; CREATE INDEX idx_placex_rank_search ON placex USING BTREE (rank_search, geometry_sector) {ts:address-index}; CREATE INDEX idx_placex_geometry ON placex USING GIST (geometry) {ts:search-index}; -CREATE INDEX idx_placex_adminname on placex USING BTREE (make_standard_name(name->'name'),rank_search) {ts:address-index} WHERE osm_type='N' and rank_search < 26; +CREATE INDEX idx_placex_adminname on placex USING BTREE (make_standard_name(name->'name')) {ts:address-index} WHERE osm_type='N' and rank_search < 26; +CREATE INDEX idx_placex_wikidata on placex USING BTREE ((extratags -> 'wikidata')) {ts:address-index} WHERE extratags ? 'wikidata' and class = 'place' and osm_type = 'N' and rank_search < 26; DROP SEQUENCE IF EXISTS seq_place; CREATE SEQUENCE seq_place start 1; @@ -188,26 +189,6 @@ GRANT SELECT ON planet_osm_ways to "{www-user}" ; GRANT SELECT ON planet_osm_rels to "{www-user}" ; GRANT SELECT on location_area to "{www-user}" ; --- insert creates the location tables, creates location indexes if indexed == true -CREATE TRIGGER placex_before_insert BEFORE INSERT ON placex - FOR EACH ROW EXECUTE PROCEDURE placex_insert(); -CREATE TRIGGER osmline_before_insert BEFORE INSERT ON location_property_osmline - FOR EACH ROW EXECUTE PROCEDURE osmline_insert(); - --- update insert creates the location tables -CREATE TRIGGER placex_before_update BEFORE UPDATE ON placex - FOR EACH ROW EXECUTE PROCEDURE placex_update(); -CREATE TRIGGER osmline_before_update BEFORE UPDATE ON location_property_osmline - FOR EACH ROW EXECUTE PROCEDURE osmline_update(); - --- diff update triggers -CREATE TRIGGER placex_before_delete AFTER DELETE ON placex - FOR EACH ROW EXECUTE PROCEDURE placex_delete(); -CREATE TRIGGER place_before_delete BEFORE DELETE ON place - FOR EACH ROW EXECUTE PROCEDURE place_delete(); -CREATE TRIGGER place_before_insert BEFORE INSERT ON place - FOR EACH ROW EXECUTE PROCEDURE place_insert(); - -- Table for synthetic postcodes. DROP TABLE IF EXISTS location_postcode; CREATE TABLE location_postcode ( @@ -224,9 +205,6 @@ CREATE TABLE location_postcode ( CREATE INDEX idx_postcode_geometry ON location_postcode USING GIST (geometry) {ts:address-index}; GRANT SELECT ON location_postcode TO "{www-user}" ; -CREATE TRIGGER location_postcode_before_update BEFORE UPDATE ON location_postcode - FOR EACH ROW EXECUTE PROCEDURE postcode_update(); - DROP TABLE IF EXISTS import_polygon_error; CREATE TABLE import_polygon_error ( osm_id BIGINT, @@ -282,3 +260,6 @@ CREATE TABLE wikipedia_redirect ( ); ALTER TABLE ONLY wikipedia_redirect ADD CONSTRAINT wikipedia_redirect_pkey PRIMARY KEY (language, from_title); +-- osm2pgsql does not create indexes on the middle tables for Nominatim +-- Add one for lookup of associated street relations. +CREATE INDEX planet_osm_rels_parts_associated_idx ON planet_osm_rels USING gin(parts) WHERE tags @> ARRAY['associatedStreet'];