-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reindex external indexes properly on updates #282
- Loading branch information
1 parent
5cea216
commit 192a4f2
Showing
2 changed files
with
26 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
-- Database updates | ||
-- Must be run in update scripts every time index storage format changes and a finer-grained update | ||
-- method is not shipped for the format change | ||
CREATE OR REPLACE FUNCTION _lantern_internal.reindex_lantern_indexes() | ||
RETURNS VOID AS $$ | ||
DECLARE | ||
r RECORD; | ||
BEGIN | ||
FOR r IN SELECT indexname, indexdef FROM pg_indexes | ||
WHERE indexdef ILIKE '%USING hnsw%' OR indexdef ILIKE '%USING lantern_hnsw%' | ||
LOOP | ||
RAISE NOTICE 'Reindexing index: %', r.indexname; | ||
IF POSITION('_experimental_index_path' in r.indexdef) > 0 THEN | ||
PERFORM lantern_reindex_external_index(r.indexname::regclass); | ||
ELSE | ||
EXECUTE 'REINDEX INDEX ' || quote_ident(r.indexname) || ';'; | ||
END IF; | ||
RAISE NOTICE 'Reindexed index: %', r.indexname; | ||
END LOOP; | ||
END $$ LANGUAGE plpgsql VOLATILE; |