]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/partition-tables.src.sql
for postcodes use rank_search as base rank for finding addresses
[nominatim.git] / lib-sql / partition-tables.src.sql
1 -- SPDX-License-Identifier: GPL-2.0-only
2 --
3 -- This file is part of Nominatim. (https://nominatim.org)
4 --
5 -- Copyright (C) 2022 by the Nominatim developer community.
6 -- For a full list of authors see the git log.
7
8 drop table IF EXISTS search_name_blank CASCADE;
9 CREATE TABLE search_name_blank (
10   place_id BIGINT,
11   address_rank smallint,
12   name_vector integer[],
13   centroid GEOMETRY(Geometry, 4326)
14   );
15
16
17 {% for partition in db.partitions %}
18   CREATE TABLE location_area_large_{{ partition }} () INHERITS (location_area_large) {{db.tablespace.address_data}};
19   CREATE INDEX idx_location_area_large_{{ partition }}_place_id ON location_area_large_{{ partition }} USING BTREE (place_id) {{db.tablespace.address_index}};
20   CREATE INDEX idx_location_area_large_{{ partition }}_geometry ON location_area_large_{{ partition }} USING GIST (geometry) {{db.tablespace.address_index}};
21
22   CREATE TABLE search_name_{{ partition }} () INHERITS (search_name_blank) {{db.tablespace.address_data}};
23   CREATE INDEX idx_search_name_{{ partition }}_place_id ON search_name_{{ partition }} USING BTREE (place_id) {{db.tablespace.address_index}};
24   CREATE INDEX idx_search_name_{{ partition }}_centroid_street ON search_name_{{ partition }} USING GIST (centroid) {{db.tablespace.address_index}} where address_rank between 26 and 27;
25   CREATE INDEX idx_search_name_{{ partition }}_centroid_place ON search_name_{{ partition }} USING GIST (centroid) {{db.tablespace.address_index}} where address_rank between 2 and 25;
26
27   DROP TABLE IF EXISTS location_road_{{ partition }};
28   CREATE TABLE location_road_{{ partition }} (
29     place_id BIGINT,
30     partition SMALLINT,
31     country_code VARCHAR(2),
32     geometry GEOMETRY(Geometry, 4326)
33     ) {{db.tablespace.address_data}};
34   CREATE INDEX idx_location_road_{{ partition }}_geometry ON location_road_{{ partition }} USING GIST (geometry) {{db.tablespace.address_index}};
35   CREATE INDEX idx_location_road_{{ partition }}_place_id ON location_road_{{ partition }} USING BTREE (place_id) {{db.tablespace.address_index}};
36
37 {% endfor %}