X-Git-Url: https://git.openstreetmap.org./nominatim.git/blobdiff_plain/f3f542e86454e6f42f7f2c4adf74eabc2d78c011..922352e21563c6eda64ff0707308ad4fd2407b53:/nominatim/tools/migration.py diff --git a/nominatim/tools/migration.py b/nominatim/tools/migration.py index d5806097..147a9f9c 100644 --- a/nominatim/tools/migration.py +++ b/nominatim/tools/migration.py @@ -332,3 +332,19 @@ def add_place_deletion_todo_table(conn: Connection, **_: Any) -> None: class TEXT, type TEXT, deferred BOOLEAN)""") + + +@_migration(4, 1, 99, 1) +def split_pending_index(conn: Connection, **_: Any) -> None: + """ Reorganise indexes for pending updates. + """ + if conn.table_exists('place'): + with conn.cursor() as cur: + cur.execute("""CREATE INDEX IF NOT EXISTS idx_placex_rank_address_sector + ON placex USING BTREE (rank_address, geometry_sector) + WHERE indexed_status > 0""") + cur.execute("""CREATE INDEX IF NOT EXISTS idx_placex_rank_boundaries_sector + ON placex USING BTREE (rank_search, geometry_sector) + WHERE class = 'boundary' and type = 'administrative' + and indexed_status > 0""") + cur.execute("DROP INDEX IF EXISTS idx_placex_pendingsector")