]> git.evergreen-ils.org Git - Evergreen.git/blob - docs/RELEASE_NOTES_NEXT/Architecture/GIST_to_GIN_indexes_FTS.adoc
Lp 1703658: Repair DB Upgrade
[Evergreen.git] / docs / RELEASE_NOTES_NEXT / Architecture / GIST_to_GIN_indexes_FTS.adoc
1 Migration From GIST to GIN Indexes for Full Text Search
2 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3
4 Evergreen now uses GIN indexes for full text search in PostgreSQL.
5 GIN indexes offer better performance than GIST.  For more information
6 on the differences in the two index types, please refer to the
7 https://www.postgresql.org/docs/current/textsearch-indexes.html[PostgreSQL
8 documentation].
9
10 An upgrade script is provided as part of this migration.  If you
11 upgrade normally from a previous release of Evergreen, this upgrade
12 script should run as part of the upgrade process.  The migration
13 script recommends that you run a `VACUUM ANALYZE` in Postgresql on the
14 tables that had the indexes changed.  The migration process does not
15 do this for you, so you should do it as soon as is convenient after
16 the upgrade.
17
18 Updating Your Own Indexes
19 +++++++++++++++++++++++++
20
21 If you have added your own full text indexes of type GIST, and you
22 wish to migrate them to GIN, you may do so.  The following query, when
23 run in your Evergreen databsase after the migration from GIST to GIN,
24 will identify the remaining GIST indexes in your database:
25
26 [source,sql]
27 ----------------------------------------
28 SELECT schemaname, indexname
29 FROM pg_indexes
30 WHERE indexdef ~* 'gist';
31 ----------------------------------------
32
33 If the above query produces output, you can run the next query to
34 output a SQL script to migrate the remaining indexes from GIST to GIN:
35
36 [source,sql]
37 ----------------------------------------
38 SELECT 'DROP INDEX ' || schemaname || '.' || indexname || E';\n' ||
39        REGEXP_REPLACE(indexdef, 'gist', 'gin', 'i') || E';\n' ||
40        'VACUUM ANAlYZE ' || schemaname || '.' || tablename || ';'
41 FROM pg_indexes
42 WHERE indexdef ~* 'gist';
43 ----------------------------------------