]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/tables.sql
Merge pull request #3982 from lonvia/split-table-creation
[nominatim.git] / lib-sql / tables.sql
1 -- SPDX-License-Identifier: GPL-2.0-only
2 --
3 -- This file is part of Nominatim. (https://nominatim.org)
4 --
5 -- Copyright (C) 2026 by the Nominatim developer community.
6 -- For a full list of authors see the git log.
7
8 DROP SEQUENCE IF EXISTS seq_place;
9 CREATE SEQUENCE seq_place start 1;
10
11 {% include('tables/status.sql') %}
12 {% include('tables/nominatim_properties.sql') %}
13 {% include('tables/location_area.sql') %}
14 {% include('tables/tiger.sql') %}
15 {% include('tables/interpolation.sql') %}
16 {% include('tables/search_name.sql') %}
17 {% include('tables/addressline.sql') %}
18 {% include('tables/placex.sql') %}
19 {% include('tables/postcodes.sql') %}
20 {% include('tables/entrance.sql') %}
21 {% include('tables/import_reports.sql') %}
22 {% include('tables/importance_tables.sql') %}
23
24 -- osm2pgsql does not create indexes on the middle tables for Nominatim
25 -- Add one for lookup of associated street relations.
26 {% if db.middle_db_format == '1' %}
27 CREATE INDEX planet_osm_rels_parts_associated_idx ON planet_osm_rels USING gin(parts)
28   {{db.tablespace.address_index}}
29   WHERE tags @> ARRAY['associatedStreet'];
30 {% else %}
31 CREATE INDEX planet_osm_rels_relation_members_idx ON planet_osm_rels USING gin(planet_osm_member_ids(members, 'R'::character(1)))
32   WITH (fastupdate=off)
33   {{db.tablespace.address_index}};
34 {% endif %}
35
36 -- Needed for lookups if a node is part of an interpolation.
37 CREATE INDEX IF NOT EXISTS idx_place_interpolations
38     ON place USING gist(geometry) {{db.tablespace.address_index}}
39     WHERE osm_type = 'W' and address ? 'interpolation';