1 -- Indices used only during search and update.
2 -- These indices are created only after the indexing process is done.
4 CREATE INDEX {{sql.if_index_not_exists}} idx_word_word_id
5 ON word USING BTREE (word_id) {{db.tablespace.search_index}};
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}};
10 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_search
11 ON placex USING BTREE (rank_search) {{db.tablespace.search_index}};
13 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_address
14 ON placex USING BTREE (rank_address) {{db.tablespace.search_index}};
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;
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;
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;
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}};
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}};
38 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
39 ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
41 -- Indices only needed for updating.
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;
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}};
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}};
55 -- Indices only needed for search.
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}};
65 {% if postgres.has_index_non_key_column %}
66 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_housenumber
67 ON placex USING btree (parent_place_id) INCLUDE (housenumber) WHERE housenumber is not null;
68 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id_with_hnr
69 ON location_property_osmline USING btree(parent_place_id) INCLUDE (startnumber, endnumber);