-DROP SEQUENCE seq_place;
-CREATE SEQUENCE seq_place start 1;
-GRANT SELECT on placex to "www-data" ;
-GRANT UPDATE ON placex to "www-data" ;
-GRANT SELECT ON search_name to "www-data" ;
-GRANT DELETE on search_name to "www-data" ;
-GRANT INSERT on search_name to "www-data" ;
-GRANT SELECT on place_addressline to "www-data" ;
-GRANT INSERT ON place_addressline to "www-data" ;
-GRANT DELETE on place_addressline to "www-data" ;
-GRANT SELECT ON seq_word to "www-data" ;
-GRANT UPDATE ON seq_word to "www-data" ;
-GRANT INSERT ON word to "www-data" ;
-GRANT SELECT ON planet_osm_ways to "www-data" ;
-GRANT SELECT ON planet_osm_rels to "www-data" ;
-GRANT SELECT on location_area to "www-data" ;
-GRANT SELECT on country to "www-data" ;
-
--- insert creates the location tagbles, creates location indexes if indexed == true
-CREATE TRIGGER placex_before_insert BEFORE INSERT ON placex
- FOR EACH ROW EXECUTE PROCEDURE placex_insert();
-
--- update insert creates the location tables
-CREATE TRIGGER placex_before_update BEFORE UPDATE ON placex
- FOR EACH ROW EXECUTE PROCEDURE placex_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();
-
-alter table placex add column geometry_sector INTEGER;
-alter table placex add column indexed_status INTEGER;
-alter table placex add column indexed_date TIMESTAMP;
-
-update placex set geometry_sector = geometry_sector(geometry);
-drop index idx_placex_pendingbylatlon;
-drop index idx_placex_interpolation;
-drop index idx_placex_sector;
-CREATE INDEX idx_placex_pendingbylatlon ON placex USING BTREE (geometry_index(geometry_sector,indexed,name),rank_search)
- where geometry_index(geometry_sector,indexed,name) IS NOT NULL;
-CREATE INDEX idx_placex_interpolation ON placex USING BTREE (geometry_sector) where indexed = false and class='place' and type='houses';
-CREATE INDEX idx_placex_sector ON placex USING BTREE (geometry_sector,rank_address,osm_type,osm_id);