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_osmline_parent_place_id
27 ON location_property_osmline USING BTREE (parent_place_id) {{db.tablespace.search_index}};
29 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id
30 ON location_property_osmline USING BTREE (osm_id) {{db.tablespace.search_index}};
32 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
33 ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
35 -- Indices only needed for updating.
38 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_pendingsector
39 ON placex USING BTREE (rank_address,geometry_sector) {{db.tablespace.address_index}}
40 WHERE indexed_status > 0;
42 CREATE INDEX {{sql.if_index_not_exists}} idx_location_area_country_place_id
43 ON location_area_country USING BTREE (place_id) {{db.tablespace.address_index}};
45 CREATE UNIQUE INDEX {{sql.if_index_not_exists}} idx_place_osm_unique
46 ON place USING btree(osm_id, osm_type, class, type) {{db.tablespace.address_index}};
49 -- Indices only needed for search.
51 {% if 'search_name' in db.tables %}
52 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_nameaddress_vector
53 ON search_name USING GIN (nameaddress_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
54 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_name_vector
55 ON search_name USING GIN (name_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
56 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_centroid
57 ON search_name USING GIST (centroid) {{db.tablespace.search_index}};
59 {% if postgres.has_index_non_key_column %}
60 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_housenumber
61 ON placex USING btree (parent_place_id) INCLUDE (housenumber) WHERE housenumber is not null;
62 CREATE INDEX {{sql.if_index_not_exists}} idx_osmline_parent_osm_id_with_hnr
63 ON location_property_osmline USING btree(parent_place_id) INCLUDE (startnumber, endnumber);