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_place_addressline_address_place_id
5 ON place_addressline USING BTREE (address_place_id) {{db.tablespace.search_index}};
7 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_search
8 ON placex USING BTREE (rank_search) {{db.tablespace.search_index}};
10 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_rank_address
11 ON placex USING BTREE (rank_address) {{db.tablespace.search_index}};
13 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_parent_place_id
14 ON placex USING BTREE (parent_place_id) {{db.tablespace.search_index}}
15 WHERE parent_place_id IS NOT NULL;
17 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_geometry_reverse_lookupPolygon
18 ON placex USING gist (geometry) {{db.tablespace.search_index}}
19 WHERE St_GeometryType(geometry) in ('ST_Polygon', 'ST_MultiPolygon')
20 AND rank_address between 4 and 25 AND type != 'postcode'
21 AND name is not null AND indexed_status = 0 AND linked_place_id is null;
23 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_place_id
24 ON location_property_osmline USING BTREE (parent_place_id) {{db.tablespace.search_index}};
26 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id
27 ON location_property_osmline USING BTREE (osm_id) {{db.tablespace.search_index}};
29 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
30 ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
32 -- Indices only needed for updating.
35 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_pendingsector
36 ON placex USING BTREE (rank_address,geometry_sector) {{db.tablespace.address_index}}
37 WHERE indexed_status > 0;
39 CREATE INDEX {{sql.if_index_not_exists}} idx_location_area_country_place_id
40 ON location_area_country USING BTREE (place_id) {{db.tablespace.address_index}};
42 CREATE UNIQUE INDEX {{sql.if_index_not_exists}} idx_place_osm_unique
43 ON place USING btree(osm_id, osm_type, class, type) {{db.tablespace.address_index}};
46 -- Indices only needed for search.
48 {% if 'search_name' in db.tables %}
49 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_nameaddress_vector
50 ON search_name USING GIN (nameaddress_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
51 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_name_vector
52 ON search_name USING GIN (name_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
53 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_centroid
54 ON search_name USING GIST (centroid) {{db.tablespace.search_index}};
56 {% if postgres.has_index_non_key_column %}
57 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_housenumber
58 ON placex USING btree (parent_place_id) INCLUDE (housenumber) WHERE housenumber is not null;
59 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id_with_hnr
60 ON location_property_osmline USING btree(parent_place_id) INCLUDE (startnumber, endnumber);