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 UNIQUE INDEX {{sql.if_index_not_exists}} idx_postcode_id
39 ON location_postcode USING BTREE (place_id) {{db.tablespace.search_index}};
41 CREATE INDEX {{sql.if_index_not_exists}} idx_postcode_postcode
42 ON location_postcode USING BTREE (postcode) {{db.tablespace.search_index}};
44 -- Indices only needed for updating.
47 CREATE INDEX {{sql.if_index_not_exists}} idx_placex_pendingsector
48 ON placex USING BTREE (rank_address,geometry_sector) {{db.tablespace.address_index}}
49 WHERE indexed_status > 0;
51 CREATE INDEX {{sql.if_index_not_exists}} idx_location_area_country_place_id
52 ON location_area_country USING BTREE (place_id) {{db.tablespace.address_index}};
54 CREATE UNIQUE INDEX {{sql.if_index_not_exists}} idx_place_osm_unique
55 ON place USING btree(osm_id, osm_type, class, type) {{db.tablespace.address_index}};
58 -- Indices only needed for search.
60 {% if 'search_name' in db.tables %}
61 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_nameaddress_vector
62 ON search_name USING GIN (nameaddress_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
63 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_name_vector
64 ON search_name USING GIN (name_vector) WITH (fastupdate = off) {{db.tablespace.search_index}};
65 CREATE INDEX {{sql.if_index_not_exists}} idx_search_name_centroid
66 ON search_name USING GIST (centroid) {{db.tablespace.search_index}};