comparison PostgreSQL/Plugins/PostgreSQLIndex.cpp @ 13:927264a0c137

preserve the original index
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 09 Jul 2018 18:42:34 +0200
parents 41543239072d
children dfc7002add9c
comparison
equal deleted inserted replaced
12:41543239072d 13:927264a0c137
115 115
116 int hasTrigram = 0; 116 int hasTrigram = 0;
117 if (!LookupGlobalIntegerProperty(hasTrigram, *db, t, Orthanc::GlobalProperty_HasTrigramIndex) || 117 if (!LookupGlobalIntegerProperty(hasTrigram, *db, t, Orthanc::GlobalProperty_HasTrigramIndex) ||
118 hasTrigram != 1) 118 hasTrigram != 1)
119 { 119 {
120 // Apply fix for performance issue (speed up wildcard search by using GIN trigrams) 120 /**
121 // https://www.postgresql.org/docs/current/static/pgtrgm.html 121 * Apply fix for performance issue (speed up wildcard search
122 * by using GIN trigrams). This implements the patch suggested
123 * in issue #47, BUT we also keep the original
124 * "DicomIdentifiersIndexValues", as it leads to better
125 * performance for "strict" searches (i.e. searches involving
126 * no wildcard).
127 * https://www.postgresql.org/docs/current/static/pgtrgm.html
128 * https://bitbucket.org/sjodogne/orthanc/issues/47/index-improvements-for-pg-plugin
129 **/
122 try 130 try
123 { 131 {
124 LOG(INFO) << "Trying to enable trigram matching on the PostgreSQL database to speed up wildcard searches"; 132 LOG(INFO) << "Trying to enable trigram matching on the PostgreSQL database to speed up wildcard searches";
125 db->Execute( 133 db->Execute(
126 "CREATE EXTENSION pg_trgm; " 134 "CREATE EXTENSION pg_trgm; "
127 "CREATE INDEX DicomIdentifiersIndexValues_new ON DicomIdentifiers USING gin(value gin_trgm_ops); " 135 "CREATE INDEX DicomIdentifiersIndexValues2 ON DicomIdentifiers USING gin(value gin_trgm_ops);");
128 "DROP INDEX DicomIdentifiersIndexValues; "
129 "ALTER INDEX DicomIdentifiersIndexValues_new RENAME TO DicomIdentifiersIndexValues;");
130 136
131 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 1); 137 SetGlobalIntegerProperty(*db, t, Orthanc::GlobalProperty_HasTrigramIndex, 1);
132 } 138 }
133 catch (Orthanc::OrthancException&) 139 catch (Orthanc::OrthancException&)
134 { 140 {