Optimize searching for users on Postgres (#9782)

The searches on Postgres using LIKE with prefix matching will only
use an index if it has the text_pattern_ops flag (forcing C collation).
This drops the old indexes and adds properly optimized ones.
Этот коммит содержится в:
Daniel Fiori
2018-11-09 15:34:31 -05:00
коммит произвёл Jesse Hallam
родитель 0c5f60f89b
Коммит 7a758eae72
2 изменённых файлов: 13 добавлений и 5 удалений

Просмотреть файл

@@ -521,6 +521,14 @@ func UpgradeDatabaseToVersion56(sqlStore SqlStore) {
// migrating user's accepted terms of service data into the new table
sqlStore.GetMaster().Exec("INSERT INTO UserTermsOfService SELECT Id, AcceptedTermsOfServiceId as TermsOfServiceId, :CreateAt FROM Users WHERE AcceptedTermsOfServiceId != \"\" AND AcceptedTermsOfServiceId IS NOT NULL", map[string]interface{}{"CreateAt": model.GetMillis()})
if sqlStore.DriverName() == model.DATABASE_DRIVER_POSTGRES {
sqlStore.RemoveIndexIfExists("idx_users_email_lower", "lower(Email)")
sqlStore.RemoveIndexIfExists("idx_users_username_lower", "lower(Username)")
sqlStore.RemoveIndexIfExists("idx_users_nickname_lower", "lower(Nickname)")
sqlStore.RemoveIndexIfExists("idx_users_firstname_lower", "lower(FirstName)")
sqlStore.RemoveIndexIfExists("idx_users_lastname_lower", "lower(LastName)")
}
//saveSchemaVersion(sqlStore, VERSION_5_6_0)
//}
}