3 SELECT evergreen.upgrade_deps_block_check('XXXX', :eg_version);
11 -- We only want to mess with gist indexes in stock Evergreen.
12 -- If you've added your own convert them or don't as you see fit.
15 JOIN pg_class cls ON cls.oid=idx.indexrelid
16 JOIN pg_namespace sc ON sc.oid = cls.relnamespace
17 JOIN pg_class tab ON tab.oid=idx.indrelid
18 JOIN pg_attribute at ON (at.attnum = ANY(idx.indkey) AND at.attrelid = tab.oid)
19 JOIN pg_am am ON am.oid=cls.relam
20 WHERE am.amname = 'gist'
22 'authority_full_rec_index_vector_idx',
23 'authority_simple_heading_index_vector_idx',
24 'metabib_identifier_field_entry_index_vector_idx',
25 'metabib_combined_identifier_field_entry_index_vector_idx',
26 'metabib_title_field_entry_index_vector_idx',
27 'metabib_combined_title_field_entry_index_vector_idx',
28 'metabib_author_field_entry_index_vector_idx',
29 'metabib_combined_author_field_entry_index_vector_idx',
30 'metabib_subject_field_entry_index_vector_idx',
31 'metabib_combined_subject_field_entry_index_vector_idx',
32 'metabib_keyword_field_entry_index_vector_idx',
33 'metabib_combined_keyword_field_entry_index_vector_idx',
34 'metabib_series_field_entry_index_vector_idx',
35 'metabib_combined_series_field_entry_index_vector_idx',
36 'metabib_full_rec_index_vector_idx'
45 RAISE NOTICE 'Converting GIST indexes into GIN indexes...';
47 FOR ind IN SELECT sc.nspname AS sch, tab.relname AS tab, cls.relname AS idx, at.attname AS col
49 JOIN pg_class cls ON cls.oid=idx.indexrelid
50 JOIN pg_namespace sc ON sc.oid = cls.relnamespace
51 JOIN pg_class tab ON tab.oid=idx.indrelid
52 JOIN pg_attribute at ON (at.attnum = ANY(idx.indkey) AND at.attrelid = tab.oid)
53 JOIN pg_am am ON am.oid=cls.relam
54 WHERE am.amname = 'gist'
56 'authority_full_rec_index_vector_idx',
57 'authority_simple_heading_index_vector_idx',
58 'metabib_identifier_field_entry_index_vector_idx',
59 'metabib_combined_identifier_field_entry_index_vector_idx',
60 'metabib_title_field_entry_index_vector_idx',
61 'metabib_combined_title_field_entry_index_vector_idx',
62 'metabib_author_field_entry_index_vector_idx',
63 'metabib_combined_author_field_entry_index_vector_idx',
64 'metabib_subject_field_entry_index_vector_idx',
65 'metabib_combined_subject_field_entry_index_vector_idx',
66 'metabib_keyword_field_entry_index_vector_idx',
67 'metabib_combined_keyword_field_entry_index_vector_idx',
68 'metabib_series_field_entry_index_vector_idx',
69 'metabib_combined_series_field_entry_index_vector_idx',
70 'metabib_full_rec_index_vector_idx'
73 -- Move existing index out of the way so there's no difference between new databases and upgraded databases
74 EXECUTE FORMAT('ALTER INDEX %I.%I RENAME TO %I_gist', ind.sch, ind.idx, ind.idx);
76 -- Meet the new index, same as the old index (almost)
77 EXECUTE FORMAT('CREATE INDEX %I ON %I.%I USING GIN (%I)', ind.idx, ind.sch, ind.tab, ind.col);
79 -- And drop the old index
80 EXECUTE FORMAT('DROP INDEX %I.%I_gist', ind.sch, ind.idx);
82 tablist := tablist || ' ' || ind.sch || '.' || ind.tab || E'\n';
86 RAISE NOTICE E'Conversion Complete.\n\n You should run a VACUUM ANALYZE on the following tables soon:\n%', tablist;