]> git.openstreetmap.org Git - nominatim.git/blob - lib-sql/indices.sql
create postcode id index earlier
[nominatim.git] / lib-sql / indices.sql
1 -- Indices used only during search and update.
2 -- These indices are created only after the indexing process is done.
3
4 CREATE INDEX {{sql.if_index_not_exists}} idx_word_word_id
5   ON word USING BTREE (word_id) {{db.tablespace.search_index}};
6
7 CREATE INDEX {{sql.if_index_not_exists}} idx_place_addressline_address_place_id
8   ON place_addressline USING BTREE (address_place_id) {{db.tablespace.search_index}};
9
10 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_search
11   ON placex USING BTREE (rank_search) {{db.tablespace.search_index}};
12
13 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_address
14   ON placex USING BTREE (rank_address) {{db.tablespace.search_index}};
15
16 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_parent_place_id
17   ON placex USING BTREE (parent_place_id) {{db.tablespace.search_index}}
18   WHERE parent_place_id IS NOT NULL;
19
20 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_geometry_reverse_lookupPolygon
21   ON placex USING gist (geometry) {{db.tablespace.search_index}}
22   WHERE St_GeometryType(geometry) in ('ST_Polygon', 'ST_MultiPolygon')
23     AND rank_address between 4 and 25 AND type != 'postcode'
24     AND name is not null AND indexed_status = 0 AND linked_place_id is null;
25
26 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_geometry_reverse_placeNode
27   ON placex USING gist (geometry) {{db.tablespace.search_index}}
28   WHERE osm_type = 'N' AND rank_search between 5 and 25
29     AND class = 'place' AND type != 'postcode'
30     AND name is not null AND indexed_status = 0 AND linked_place_id is null;
31
32 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_place_id
33   ON location_property_osmline USING BTREE (parent_place_id) {{db.tablespace.search_index}};
34
35 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id
36   ON location_property_osmline USING BTREE (osm_id) {{db.tablespace.search_index}};
37
38 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
39   ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
40
41 -- Indices only needed for updating.
42
43 {% if not drop %}
44   CREATE INDEX {{sql.if_index_not_exists}} idx_placex_pendingsector
45     ON placex USING BTREE (rank_address,geometry_sector) {{db.tablespace.address_index}}
46     WHERE indexed_status > 0;
47
48   CREATE INDEX {{sql.if_index_not_exists}} idx_location_area_country_place_id
49     ON location_area_country USING BTREE (place_id) {{db.tablespace.address_index}};
50
51   CREATE UNIQUE INDEX {{sql.if_index_not_exists}} idx_place_osm_unique
52     ON place USING btree(osm_id, osm_type, class, type) {{db.tablespace.address_index}};
53 {% endif %}
54
55 -- Indices only needed for search.
56
57 {% if 'search_name' in db.tables %}
58   CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_nameaddress_vector
59     ON search_name USING GIN (nameaddress_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
60   CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_name_vector
61     ON search_name USING GIN (name_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
62   CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_centroid
63     ON search_name USING GIST (centroid) {{db.tablespace.search_index}};
64 {% endif %}